Shared functions and methods

Custom Exceptions


class ibmdbpy.exceptions.Error(message)[source]

This is the base class of all other exceptions thrown by ibmdbpy. It can be used to catch all exceptions with a single except statement.


class ibmdbpy.exceptions.IdaDataBaseError(message)[source]

This exception is raised when an error occurs while you manipulate the IdaDataBase interface.


class ibmdbpy.exceptions.IdaDataFrameError(message)[source]

This exception is raised when an error occurs while you manipulate the IdaDataFrame interface.


class ibmdbpy.exceptions.PrimaryKeyError(message)[source]

This exception is raised when an error occurs because of a missing or eroneous primary key column.


class ibmdbpy.exceptions.IdaKMeansError(message)[source]

This exception is raised when an error related to the ibmdbpy KMeans clustering occurs.


class ibmdbpy.exceptions.IdaAssociationRulesError(message)[source]

This exception is raised when an error related to ibmdbpy Association Rules occurs.


class ibmdbpy.exceptions.IdaNaiveBayesError(message)[source]

This exception is raised when an error related to ibmdbpy Naive Bayes occurs.

User Interactions

Configuring the environment


Set the environment variable “VERBOSE” to ‘TRUE’ or ‘FALSE’. If it is set to ‘TRUE’, all SQL request are printed in the console.


Set the environment variable “AUTCOMMIT” to ‘TRUE’ or ‘FALSE’. If it is set to ‘TRUE’, all operations are committed automatically.

Performance Monitoring


Measure the elapsed time of custom functions of the package. Should be used as a decorator.

User prompt

ibmdbpy.utils.query_yes_no(question, default=None)[source]

Ask a yes/no question via raw_input() and return its answer.


question : str

Question to be asked to the user. Should be a yes/no question.

default : “yes”/”no”

The presumed answer if the user just hits <Enter>.



Legagy from benchmark

ibmdbpy.utils.chunklist(l, n)[source]

Yield successive n-sized chunks from l.


Decorate that silent the function it decorates, i.e SQL queries will not be printed.


  • Legagy from Benchmark submodule
ibmdbpy.utils.to_nK(dataframe, nKrow)[source]

Create a version of the dataframe that has n Krows.


dataframe : DataFrame

DataFrame to use as a basis

nKrow : int

Number of Krows the return dataframe should contain



A Version of the inputed dataframe with n Krows


  • If the dataset is smaller than nKrow, it will be imputed randomly

with some existing rows, otherwise ve return a random sample

  • Legagy from Benchmark submodule
ibmdbpy.utils.extend_dataset(df, n)[source]

Extend a dataframe horizontaly by duplicating its columns n times

Convention checking

Name checking


Check if a string is upper case. This function converts the string to upper case and checks if it is a valid table name.


tablename : str

string to be checked.



Checked and upper cased table name.


Table names should consist of upper case characters or numbers that can be separated by underscores (“_”) characters.


Convenience function. Just an alternative name to check_tablename for checking view names, which have the same prerequisites as tablenames. See the check_tablename documentation.


Check if the name given as parameter is in upper case and convert it to upper cases.

Private functions


ibmdbpy.utils._convert_dtypes(idadf, data)[source]

DEPRECATED - CURRENTLY NOT IN USE was used for formatting dataframe types

Convert datatypes in a dataframe to float or to int according to the corresponding type in database. This function only works if the dataframe that is given as a parameter has the same columns as the current IdaDataFrame.


ibmdbpy.utils._reset_attributes(idaobject, attributes)[source]

Delete an attribute of a list of attributes of an object, if the attribute exists.