sql_tools

File Purpose: misc. tools related to SQL.

Note that many of these solve the same issues that SQLAlchemy solves.

If you already know SQL well, maybe it would be better to use SQLAlchemy.
But, these tools were added so that PlasmaCalcs developers and users
can maybe learn SQL more easily, with less of the SQLAlchemy abstraction.

Functions

_maybe_assert_sql_location_exists(location, *)

depending on assert_exists, may assert location exists or that it does not exist.

_sqlglot_suppress_warnings()

context manager to suppress sqlglot warnings, e.g. about unsupported features of a dialect.

sql_engine_backend(engine)

return sql engine "backend" implied by engine string.

sql_engine_from_location(location)

returns sql engine implied by location string.

sql_location_string([location])

returns "normalized" location string from location input.

sql_to_postgres(sql, *[, dialect, as_list, ...])

transpile sql statement into postgres.

Classes

PostgresConnection(location)

class which wraps a database connection to an online PostgreSQL database.

SqlBase([location, assert_exists])

class which provides some basic SQL-related tools for a database connection.

Sqlite3InMemoryConnection(*[, con, ...])

class which mimics a database connection to an in-memory database.