module dbengine
¶
Short summary¶
module lightmlboard.dbengine
Manages a sqlite3 database.
Classes¶
class |
truncated documentation |
---|---|
Common functions about sqlite3. |
|
Exception raised by class |
Methods¶
method |
truncated documentation |
---|---|
Check the SQL connection. |
|
Tells if the database takes place in memory ( |
|
Close the database. |
|
Call this function after any insert request. |
|
Opens a connection to the database. |
|
Creates a table. |
|
Open a cursor with a query and return it to the user. |
|
Returns the file name. |
|
Returns the list of tables. |
|
Tells if a table has rows. |
Documentation¶
Manages a sqlite3 database.
- class lightmlboard.dbengine.Database(dbfile)¶
Bases:
object
Common functions about sqlite3.
- Parameters:
dbfile – filename or
:memory:
- __init__(dbfile)¶
- Parameters:
dbfile – filename or
:memory:
- _check_connection()¶
Check the SQL connection.
- _field_option = ['PRIMARYKEY', 'AUTOINCREMENT', 'AUTOFILL']¶
- _is_memory()¶
Tells if the database takes place in memory (
:memory:
).
- close()¶
Close the database.
- commit()¶
Call this function after any insert request.
- connect()¶
Opens a connection to the database.
- create_table(table, columns, temporary=False)¶
Creates a table.
- Parameters:
table – table name
columns –
columns definition, dictionary
{ key:(column_name,python_type) }
ifPRIMARYKEY
is added, the key is considered as the primary key. Example:columns = { -1:("key", int, "PRIMARYKEY", "AUTOINCREMENT"), 0:("name",str), 1:("number", float) }
temporary – if True the table is temporary
- Returns:
cursor
- execute(request)¶
Open a cursor with a query and return it to the user.
- Parameters:
request – SQL request
- Returns:
cursor
- get_file()¶
Returns the file name.
- get_table_list()¶
Returns the list of tables.
- Returns:
the table list
- has_rows(table)¶
Tells if a table has rows.
- Parameters:
table – table name
- Returns:
boolean