luminadb.database module

SQLite Database

class luminadb.database.Database(path: str, **kwargs)[source]

Bases: object

Sqlite3 database, this provide basic integration.

Custom flags:

strict : Certain actions are prevented when active, i.e, initializing nonexistent tables forgive: Certain actions are replaced when active, i.e, replacing .create_table to .table

when a table exists

check_table(table: str)[source]

Check if table is exists or not.

close()[source]

Close database

property closed

Is database closed?

commit()[source]

Commit changes to database

create_index(index: Index)[source]

Create an index

create_table(table: str, columns: Iterable[Column] | Iterable[BuilderColumn])[source]

Create table

Parameters:
  • table (str) – Table name

  • columns (Iterable[Column]) – Columns for table

Returns:

Newly created table

Return type:

Table

cursor() WithCursor[source]

Create cursor

delete_index(name: str | Index, exists_ok: bool = False)[source]

Drop an index

delete_table(table: str)[source]

Delete an existing table

Parameters:

table (str) – table name

foreign_pragma(bool_state: Literal['ON', 'OFF', ''] = '')[source]

Enable/disable foreign key pragma

optimize()[source]

Optimize current database

property path

Path to SQL Connection

rename_table(old_table: str, new_table: str) Table[source]

Rename existing table to a new one.

reset_table(table: str, columns: Iterable[Column] | Iterable[BuilderColumn]) Table[source]

Reset existing table with new, this rewrote entire table than altering it.

rollback()[source]

Rollback changes

shrink_memory()[source]

Shrink memories from database as much as it can.

property sql

SQL Connection

table(table: str, _Database__columns: Iterable[Column] | None = None)[source]

fetch table

tables() tuple[Table, ...][source]

Return tuple containing all table except internal tables

vacuum()[source]

Vacuum this database