OLTPConnection#
- class swordfish.connection.OLTPConnection(impl)#
Manages connections to OLTP databases.
Examples
>>> import swordfish as sf >>> conn = sf.connect(url="/path/to/file")
- create_table(name, types, primary, secondary=None)#
Creates a new table in the database.
- Parameters:
name (str) – The name of the table to create.
types (TypeDict) – A dictionary specifying the column names and their data types.
primary (list of str or str) – The primary key of the table.
secondary (list of tuple, optional) – Secondary indexes or constraints for the table. Defaults to None.
- Returns:
A new table created based on the given parameters.
- Return type:
Examples
>>> conn.create_table("table_name", { ... 'a': "INT", ... 'b': "INT", ... 'c': "BOOL", ... 'd': "LONG", ... 'e': "STRING", ... }, "a", [[True, ["b", "c", "d"]], [False, ["d"]]])
- drop_table(name)#
Drops a table from the database.
- Parameters:
name (str) – The name of the table to drop.
Examples
>>> conn.drop_table("table_name")
- list_tables()#
Retrieves the names of all tables in the database.
- Returns:
A list of table names in the database.
- Return type:
list
Examples
>>> conn.list_tables()
- exists_table(name)#
- Parameters:
name (str)
- Return type:
bool