template_base Package
template_base Package
This package houses the additional static python files that are required for the application that is generated
to work successfully.
connections_reader Module
This file houses the code that reads in the connections file and instantiates an array of connections keyed on the
connection name for use by the generated application.
sqlalchemy_connector Module
This file contains all of the necessary components for the application to connect to a data source via
SQLAlchemy.
-
class etlunit.template_base.sqlalchemy_connector.CustomEncoder(skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, encoding='utf-8', default=None)[source]
Bases: json.encoder.JSONEncoder
This class is a custom JSON encoder. Only required if we need to jsonify datetimes.
-
default(obj)[source]
Method to actually perform the jsonifying action.
| Parameters: | obj – The object that we are jsonifying. |
| Returns: | Jsonified object. |
-
class etlunit.template_base.sqlalchemy_connector.DB_Connector(conn_name)[source]
-
deleteFrom(table_name)[source]
This method deletes all records from a table.
| Parameters: | table_name (str.) – Name of the table that we want to delete from. |
-
getCount(table_name)[source]
This method gets a count of records given a table_name.
| Parameters: | table_name (str.) – Name of the table that we want to count records from. |
| Returns: | SQLAlchemy result of the count. |
-
getTable(table_name)[source]
This method gets a table given a name through SQLAlchemy’s reflection capability.
| Parameters: | table_name (str.) – Name of the table that we want to instantiate. |
| Returns: | SQLAlchemy Table object. |
-
insertInto(table_name, records)[source]
This method inserts given records into a table.
| Parameters: |
- table_name (arr.) – Name of the table that we want to insert into.
- records – A key, value pair of records to insert.
|
-
selectFrom(table_name)[source]
This method selects all from a table.
| Parameters: | table_name (str.) – Name of the table that we want to select from. |
| Returns: | A jsonified result from SQLAlchemy. |
-
to_json(qry_results, table)[source]
This method jsonifies the SQLAlchemy query result.
| Parameters: | qry_results (SQLAlchemy ResultSet.) – Results from SQLAlchemy’s query call. |
| Returns: | Jsonified SQLAlchemy ResultSet. |