sillyorm.dbms package

Submodules

sillyorm.dbms.sqlite module

class sillyorm.dbms.sqlite.SQLiteConnection(*args: Any, **kwargs: Any)

Bases: Connection

SQLite database connection abstraction

All parameters passed to the Constructor of this class get passed to sqlite3.connect

close() None

Closes the connection

cursor() SQLiteCursor

Gets a database cursor from the connection

Returns:

A database cursor

Return type:

sillyorm.sql.Cursor

class sillyorm.dbms.sqlite.SQLiteCursor(cr: Cursor)

Bases: Cursor

SQLite database cursor abstraction

Parameters:

cr (sqlite3.Cursor) – cursor

case_insensitive_like() str

Returns the operator for case-insensitive like in the current DBMS

Returns:

the case-insensitive LIKE operator

Return type:

str

commit() None

Commits the current transaction

execute(sqlcode: SQL) Self

Executes SQL code

Parameters:

sqlcode (sillyorm.sql.SQL) – The SQL code

Returns:

Returns the Cursor

Return type:

sillyorm.sql.Cursor

fetchall() list[tuple[Any, ...]]

Fetches all remaining rows of the query.

Returns:

All remaining rows of the query. Empty list if nothing is available

Return type:

list[tuple[Any, …]]

fetchone() tuple[Any, ...]

Fetches the next row of the query.

Returns:

The next row of the query. None if nothing is available

Return type:

tuple[Any, …]

get_table_column_info(name: str) list[ColumnInfo]

Returns the column info of a table

Parameters:

name (str) – The name of the table

Returns:

The column info of the specified table

Return type:

list[sillyorm.sql.ColumnInfo]

rollback() None

Rolls back the current transaction

table_exists(name: str) bool

Checks if a table exists

Parameters:

name (str) – The name of the table

Returns:

whether or not the table exists

Return type:

bool

sillyorm.dbms.postgresql module

class sillyorm.dbms.postgresql.PostgreSQLConnection(connstr: str, lock_timeout: int = 5000)

Bases: Connection

PostgreSQL database connection abstraction

Parameters:
  • connstr (str) – psycopg2 connection string

  • lock_timeout (int, optional) – lock timeout in milliseconds

close() None

Closes the connection

cursor() PostgreSQLCursor

Gets a database cursor from the connection

Returns:

A database cursor

Return type:

sillyorm.sql.Cursor

class sillyorm.dbms.postgresql.PostgreSQLCursor(cr: cursor)

Bases: Cursor

PostgreSQL database cursor abstraction

Parameters:

cr (psycopg2.extensions.cursor) – cursor

commit() None

Commits the current transaction

execute(sqlcode: SQL) Self

Executes SQL code

Parameters:

sqlcode (sillyorm.sql.SQL) – The SQL code

Returns:

Returns the Cursor

Return type:

sillyorm.sql.Cursor

fetchall() list[tuple[Any, ...]]

Fetches all remaining rows of the query.

Returns:

All remaining rows of the query. Empty list if nothing is available

Return type:

list[tuple[Any, …]]

fetchone() tuple[Any, ...]

Fetches the next row of the query.

Returns:

The next row of the query. None if nothing is available

Return type:

tuple[Any, …]

get_table_column_info(name: str) list[ColumnInfo]

Returns the column info of a table

Parameters:

name (str) – The name of the table

Returns:

The column info of the specified table

Return type:

list[sillyorm.sql.ColumnInfo]

rollback() None

Rolls back the current transaction

table_exists(name: str) bool

Checks if a table exists

Parameters:

name (str) – The name of the table

Returns:

whether or not the table exists

Return type:

bool

Module contents