module sql.sql_interface_database
¶
Short summary¶
module pyensae.sql.sql_interface_database
Abstract class to connect to a SQL server using various way. It will be used to implement magic functions
Classes¶
class |
truncated documentation |
---|---|
Abstract class to connect to a SQL server using various way. It will be used to implement magic functions |
Methods¶
method |
truncated documentation |
---|---|
add a function to the database which can be called in a SELECT statement |
|
close the connection to the database |
|
connection to the database |
|
drops a table |
|
return the resuls of a SQL query |
|
returns the list of columns in a table |
|
returns the list of tables in the database |
|
import a dataframe into the database |
|
import a flat file as a table, we assume the columns separator is |
Documentation¶
Abstract class to connect to a SQL server using various way. It will be used to implement magic functions
-
class
pyensae.sql.sql_interface_database.
InterfaceSQLDatabase
(filename)[source]¶ Bases:
pyensae.sql.sql_interface.InterfaceSQL
Abstract class to connect to a SQL server using various way. It will be used to implement magic functions
- Parameters
filename – str or
Database
If filename is a
Database
, the object is kept as is.Changed in version 1.1: Parameter filename can be a database.
-
__init__
(filename)[source]¶ - Parameters
filename – str or
Database
If filename is a
Database
, the object is kept as is.Changed in version 1.1: Parameter filename can be a database.
-
add_function
(code_function)[source]¶ add a function to the database which can be called in a SELECT statement
- Parameters
code_function – pointer to the function
-
execute_clean_query
(sql_query)[source]¶ return the resuls of a SQL query
- Parameters
sql_query – query to execute
- Returns
pandas DataFrame
-
get_table_columns
(table_name, as_dict=True)[source]¶ returns the list of columns in a table
- Parameters
table_name – table name
as_dict – True, as dictionary, as a list otherwise
- Returns
dictionary { “column”: (position, type) }
-
import_dataframe
(tablename, df)[source]¶ import a dataframe into the database
- Parameters
tablename – name of the table
df – dataframe
- Returns
the number of added rows