fireant.database package

Submodules

fireant.database.base module

class fireant.database.base.Database(host=None, port=None, database=None, max_processes=1, max_result_set_size=200000, cache_middleware=None, concurrency_middleware=None)[source]

Bases: object

This is a abstract base class used for interfacing with a database platform.

connect()[source]

This function must establish a connection to the database platform and return it.

date_add(field: pypika.terms.Term, date_part: str, interval: int)[source]

This function must add/subtract a Date or Date/Time object.

fetch(query)[source]
get_column_definitions(schema, table)[source]

This function must return the columns of a given schema and table.

query_cls

alias of pypika.queries.Query

slow_query_log_min_seconds = 15
to_char(definition)[source]
trunc_date(field, interval)[source]

This function must create a Pypika function which truncates a Date or DateTime object to a specific interval.

fireant.database.mysql module

class fireant.database.mysql.DateAdd(field, interval_term, alias=None)[source]

Bases: pypika.terms.Function

Override for the MySQL specific DateAdd function which expects an interval instead of the date part and interval unit e.g. DATE_ADD(“date”, INTERVAL 1 YEAR)

class fireant.database.mysql.MySQLDatabase(host='localhost', port=3306, database=None, user=None, password=None, charset='utf8mb4', **kwags)[source]

Bases: fireant.database.base.Database

MySQL client that uses the PyMySQL module.

connect()[source]

Returns a MySQL connection

Returns:pymysql Connection class
date_add(field, date_part, interval)[source]

This function must add/subtract a Date or Date/Time object.

get_column_definitions(schema, table)[source]

Return a list of column name, column data type pairs

query_cls

alias of pypika.dialects.MySQLQuery

to_char(definition)[source]
trunc_date(field, interval)[source]

This function must create a Pypika function which truncates a Date or DateTime object to a specific interval.

class fireant.database.mysql.Trunc(field, date_format, alias=None)[source]

Bases: pypika.terms.Function

Wrapper for a custom MySQL TRUNC function (installed via a custom FireAnt MySQL script)

fireant.database.postgresql module

class fireant.database.postgresql.DateTrunc(field, date_format, alias=None)[source]

Bases: pypika.terms.Function

Wrapper for the PostgreSQL date_trunc function

class fireant.database.postgresql.PostgreSQLDatabase(host='localhost', port=5432, database=None, user=None, password=None, **kwags)[source]

Bases: fireant.database.base.Database

PostgreSQL client that uses the psycopg module.

connect()[source]

This function must establish a connection to the database platform and return it.

date_add(field, date_part, interval)[source]

This function must add/subtract a Date or Date/Time object.

get_column_definitions(schema, table)[source]

Return a list of column name, column data type pairs

query_cls

alias of pypika.dialects.PostgreSQLQuery

trunc_date(field, interval)[source]

This function must create a Pypika function which truncates a Date or DateTime object to a specific interval.

fireant.database.redshift module

class fireant.database.redshift.RedshiftDatabase(host='localhost', port=5439, database=None, user=None, password=None, **kwags)[source]

Bases: fireant.database.postgresql.PostgreSQLDatabase

Redshift client that uses the psycopg module.

query_cls

alias of pypika.dialects.RedshiftQuery

fireant.database.snowflake module

class fireant.database.snowflake.SnowflakeDatabase(user='snowflake', password=None, account='snowflake', database='snowflake', private_key_data=None, private_key_password=None, region=None, warehouse=None, **kwags)[source]

Bases: fireant.database.base.Database

Snowflake client.

DATETIME_INTERVALS = {'day': 'DD', 'hour': 'HH', 'month': 'MM', 'quarter': 'Q', 'week': 'IW', 'year': 'Y'}
connect()[source]

This function must establish a connection to the database platform and return it.

date_add(field, date_part, interval)[source]

This function must add/subtract a Date or Date/Time object.

get_column_definitions(schema, table)[source]

Return a list of column name, column data type pairs

query_cls

alias of pypika.dialects.SnowflakeQuery

trunc_date(field, interval)[source]

This function must create a Pypika function which truncates a Date or DateTime object to a specific interval.

class fireant.database.snowflake.Trunc(field, date_format, alias=None)[source]

Bases: pypika.terms.Function

Wrapper for TRUNC function for truncating dates.

fireant.database.vertica module

class fireant.database.vertica.Trunc(field, date_format, alias=None)[source]

Bases: pypika.terms.Function

Wrapper for Vertica TRUNC function for truncating dates.

class fireant.database.vertica.VerticaDatabase(host='localhost', port=5433, database='vertica', user='vertica', password=None, read_timeout=None, **kwags)[source]

Bases: fireant.database.base.Database

Vertica client that uses the vertica_python driver.

DATETIME_INTERVALS = {'day': 'DD', 'hour': 'HH', 'month': 'MM', 'quarter': 'Q', 'week': 'IW', 'year': 'Y'}
connect()[source]

This function must establish a connection to the database platform and return it.

date_add(field, date_part, interval)[source]

This function must add/subtract a Date or Date/Time object.

get_column_definitions(schema, table)[source]

Return schema information including column names and their data type

Parameters:
  • schema – the name of the schema if you would like to narrow the results down (String)
  • table – the name of the table if you would like to narrow the results down (String)
Returns:

List of column name, column data type pairs

query_cls

alias of pypika.dialects.VerticaQuery

trunc_date(field, interval)[source]

This function must create a Pypika function which truncates a Date or DateTime object to a specific interval.