glide.sql_utils module¶
SQL utilities
-
class
glide.sql_utils.
SQLiteTemporaryTable
(*args, **kwargs)[source]¶ Bases:
pandas.io.sql.SQLiteTable
Override the default Pandas SQLite table creation to make it a temp table
-
class
glide.sql_utils.
TemporaryTable
(name, pandas_sql_engine, frame=None, index=True, if_exists='fail', prefix='pandas', index_label=None, schema=None, keys=None, dtype=None)[source]¶ Bases:
pandas.io.sql.SQLTable
Override the default Pandas table creation to make it a temp table
-
glide.sql_utils.
add_table_suffix
(table, suffix)[source]¶ Helper to deal with backticks when adding table suffix
-
glide.sql_utils.
build_table_select
(table, where=None, limit=None)[source]¶ Simple helper to build a SQL query to select from a table
-
glide.sql_utils.
get_bulk_insert
(table_name, column_names, **kwargs)[source]¶ Get a bulk insert statement
-
glide.sql_utils.
get_bulk_insert_ignore
(table_name, column_names, **kwargs)[source]¶ Get a bulk insert ignore statement
-
glide.sql_utils.
get_bulk_replace
(table_name, column_names, **kwargs)[source]¶ Get a bulk replace statement
-
glide.sql_utils.
get_bulk_statement
(stmt_type, table_name, column_names, dicts=True, value_string='%s', odku=False)[source]¶ Get a SQL statement suitable for use with bulk execute functions
- Parameters
stmt_type (str) – One of REPLACE, INSERT, or INSERT IGNORE. Note: Backend support for this varies.
table_name (str) – Name of SQL table to use in statement
column_names (list) – A list of column names to load
dicts (bool, optional) – If true, assume the data will be a list of dict rows
value_string (str, optional) – The parameter replacement string used by the underyling DB API
odku (bool or list, optional) – If true, add ON DUPLICATE KEY UPDATE clause for all columns. If a list then only add it for the specified columns. Note: Backend support for this varies.
- Returns
sql – The sql query string to use with bulk execute functions
- Return type
str