dblite
1.3.0
Simple query interface for SQL databases
|
Classes | |
class | Database |
Convenience wrapper around psycopg2.ConnectionPool and Cursor. More... | |
class | Identifier |
Wrapper for table and column names from data objects. More... | |
class | Queryable |
class | RowFactoryCursor |
A cursor that generates result rows via given factory callable. More... | |
class | Transaction |
Transaction context manager, provides convenience methods for queries. More... | |
Functions | |
def | autodetect (opts) |
Returns true if input is recognizable as Postgres connection options. More... | |
def | make_db_url (opts) |
Returns Postgres connection options as URL, like `"postgresql://host/dbname"`. More... | |
def | query_schema (queryable, keys=False, views=False, inheritance=False) |
Returns database table structure populated from given database. More... | |
def | quote (value, force=False) |
Returns identifier in quotes and proper-escaped for queries, if value needs quoting (has non-alphanumerics, starts with number, or is reserved). More... | |
def | register_adapter (transformer, typeclasses) |
Registers function to auto-adapt given Python types to Postgres types in query parameters. More... | |
def | register_converter (transformer, typenames) |
Registers function to auto-convert given Postgres types to Python types in query results. More... | |
def | register_row_factory (row_factory) |
Registers custom row factory, as or `None` to reset to default. More... | |
Variables | |
list | RESERVED_KEYWORDS |
Postgres reserved keywords, needing quotes in SQL queries. More... | |
def dblite.engines.postgres.autodetect | ( | opts | ) |
Returns true if input is recognizable as Postgres connection options.
opts | expected as URL string `"postgresql://user@localhost/mydb"` or keyword=value format string like `"host=localhost dbname=.."` or a dictionary of `dict(host="localhost", dbname=..)` |
Definition at line 825 of file postgres.py.
def dblite.engines.postgres.make_db_url | ( | opts | ) |
Returns Postgres connection options as URL, like `"postgresql://host/dbname"`.
Definition at line 834 of file postgres.py.
def dblite.engines.postgres.query_schema | ( | queryable, | |
keys = False , |
|||
views = False , |
|||
inheritance = False |
|||
) |
Returns database table structure populated from given database.
queryable | Database or Transaction instance |
views | whether to include views |
keys | whether to include primary and foreign key information |
inheritance | whether to include parent-child table information and populate inherited foreign keys |
Definition at line 875 of file postgres.py.
def dblite.engines.postgres.quote | ( | value, | |
force = False |
|||
) |
Returns identifier in quotes and proper-escaped for queries, if value needs quoting (has non-alphanumerics, starts with number, or is reserved).
value | the value to quote, returned as-is if not string |
force | whether to quote value even if not required |
Definition at line 943 of file postgres.py.
def dblite.engines.postgres.register_adapter | ( | transformer, | |
typeclasses | |||
) |
Registers function to auto-adapt given Python types to Postgres types in query parameters.
Definition at line 957 of file postgres.py.
def dblite.engines.postgres.register_converter | ( | transformer, | |
typenames | |||
) |
Registers function to auto-convert given Postgres types to Python types in query results.
Definition at line 969 of file postgres.py.
def dblite.engines.postgres.register_row_factory | ( | row_factory | ) |
Registers custom row factory, as or `None` to reset to default.
Definition at line 979 of file postgres.py.
list dblite.engines.postgres.RESERVED_KEYWORDS |
Postgres reserved keywords, needing quotes in SQL queries.
Definition at line 38 of file postgres.py.