The python package can be installated using the following command using pip in your system. It requires a python version more than or equal to python 3.5.4. Information about other dependencies are given in the following sections.
- pip install eziocon
The tested and stable version of the code has the support for the following databases :
Database | Tested - Version |
---|---|
MySql | >= 5.7 |
Oracle | >=12c |
These are the following dependencies which are to be installed in your system for the proper functioning of the package. These can be done using pip commands. Eziocon is a wrapper written above them for enabling the users to interact with python objects to achieve basic SQL operations instead of creating the queries every single time.
Dependency list:
cx_oracle dependency is used to connect to oracle based SQL databases. Apart from doing a simple pip install cx_oracle in the terminal , you need have oracle based libraries setup in your system and your environment variables must be configure for the proper working of cx_oracle library.
The following link will be useful to setup *cx_oracle and **oracle client libraries **in linux,windows and mac based operating systems respectively:
The following functions are the wrappers which will be common across all the databases covered by the package w.r.t. to return types and function arguments.
This enables the user to use these member functions for data migrations across different SQL platforms via python interface.
Method to take in the following inputs instantiate the connection object to the database
Mysql Parameters :
- Hostname
- Port
- database name
- username
- password
Oracle Parameters:
- hosname
- port
- username
- password
- SID
Returns: None : Raise Value error if in case of any error
Method to return the count of records given table name and SQL where clause
- tablename : String :
Name of the table in the database
- condition : String :
SQL query : Where clause filter
Returns : Count : Integer
Method to return a single record given table name , column name and SQL where clause
- tablename : String
Name of the table in the database
- condition : String
SQL query : Where clause filter
- columns : Iterator of String : (List or tuple )
Any of the above mentioned iterators with column names of the table as values
- return_type : Integer : Default Value 1
Specifies the format in which the result has to be returned. For getting the results in Dataframe value must be 1 and for getting the results in Dictionaries the value must be 2.
Returns : Dataframe or Dictionaries
Method to return a group of records given table name , column name ,SQL where clause and number of rows
- tablename : String
Name of the table in the database
- condition : String
SQL query : Where clause filter
- columns : Iterator of String : (List or tuple )
Any of the above mentioned iterators with column names of the table as values
- rows : Integer: Default Value = -1
Number of rows that have to fetched from the database. Must be greater than 1. The default value -1 specifies fethc all the rows for the given query.
- return_type : Integer : Default Value 1
Specifies the format in which the result has to be returned. For getting the results in Dataframe value must be 1 and for getting the results in Dictionaries the value must be 2.
Returns : Dataframe or Dictionaries
Method to insert a bunch of records or a single record given the table name and data
- tablename : String
Name of the table in the database
- objects : Dictionary or List of Dictionaries : {‘column name’ : Value}
For inserting a single record pass a Dictionary with the above mentioned format and For inserting a bulk bunch of records into the Table pass a list of Dictionaries.
Returns : True : Boolean
Method to update a group of records statisfying the where clause condition given table name, Values that must be updated and SQL where clause
- tablename : String
Name of the table in the database
- updations : Dictionary : {‘column name’ : Value}
A Dictionary object which has the list of columns to be updated as the key and changes of the corresponding the columns as the respective value.
- condition : String
SQL query : Where clause filter
Returns : True : Boolean
This Blog post will give you a detail walk through of how to use and manipulate data using the above mentioned functions.
Contents:
The following enhancements will be implemented: