Query
- korus.database.backend.sqlite.query.add_column(conn, table_name, col_name, col_type, required=False, default_value=None)[source]
- korus.database.backend.sqlite.query.fetch_row(conn, table_name, indices=None, fields=None, as_dict=False, return_indices=False)[source]
- korus.database.backend.sqlite.query.insert_row(conn, table_name, row)[source]
Insert a row of values into a table in the database.
- Args:
- conn: sqlite3.Connection
Database connection
- table_name: str
Table name
- row: dict
row to be inserted
- Returns:
- c: sqlite3.Cursor
Database cursor
- Raises:
- sqlite3.IntegrityError: if the table already contains an entry with these data,
or a required value is missing, or some other requirement is not fulfilled.
- korus.database.backend.sqlite.query.query_table(conn, table_name, condition=None, indices=None)[source]
- korus.database.backend.sqlite.query.table_exists(conn, name)[source]
Check if the database already has a table with a given name
- Args:
- conn: sqlite3.Connection
Database connection
- name: str
Table name
- Returns:
- : bool
True, if table exists. False, otherwise.
- korus.database.backend.sqlite.query.to_str(x)[source]
Transform the input to a string, suitably formatted for forming SQLite queries.
Example query: SELECT * FROM y WHERE z IN {to_str(x)}
- Args:
- x:
The input
- Returns:
- : str
String
- korus.database.backend.sqlite.query.update_row(conn, table_name, idx, row)[source]
Update a row in a table in the database.
Note: Expects the table to have an id index column OBS: If a row with the specified id does not exist, it is created!
- Args:
- conn: sqlite3.Connection
Database connection
- table_name: str
Table name
- idx: int
Identifier of the row to be replaced
- row: dict
row to be inserted
- Returns:
- c: sqlite3.Cursor
Database cursor