module dbengine

Inheritance diagram of lightmlboard.dbengine

Short summary

module lightmlboard.dbengine

Manages a sqlite3 database.

source on GitHub

Classes

class

truncated documentation

Database

Common functions about sqlite3.

DBException

Exception raised by class Database.

Methods

method

truncated documentation

__init__

_check_connection

Check the SQL connection.

_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

Creates a table.

execute

Open a cursor with a query and return it to the user.

get_file

Returns the file name.

get_table_list

Returns the list of tables.

has_rows

Tells if a table has rows.

Documentation

Manages a sqlite3 database.

source on GitHub

exception lightmlboard.dbengine.DBException

Bases: Exception

Exception raised by class Database.

source on GitHub

class lightmlboard.dbengine.Database(dbfile)

Bases: object

Common functions about sqlite3.

source on GitHub

Parameters

dbfile – filename or :memory:

source on GitHub

__init__(dbfile)
Parameters

dbfile – filename or :memory:

source on GitHub

_check_connection()

Check the SQL connection.

source on GitHub

_field_option = ['PRIMARYKEY', 'AUTOINCREMENT', 'AUTOFILL']
_is_memory()

Tells if the database takes place in memory (:memory:).

source on GitHub

close()

Close the database.

source on GitHub

commit()

Call this function after any insert request.

source on GitHub

connect()

Opens a connection to the database.

source on GitHub

create_table(table, columns, temporary=False)

Creates a table.

Parameters
  • table – table name

  • columns

    columns definition, dictionary { key:(column_name,python_type) } if PRIMARYKEY 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

source on GitHub

execute(request)

Open a cursor with a query and return it to the user.

Parameters

request – SQL request

Returns

cursor

source on GitHub

get_file()

Returns the file name.

source on GitHub

get_table_list()

Returns the list of tables.

Returns

the table list

source on GitHub

has_rows(table)

Tells if a table has rows.

Parameters

table – table name

Returns

boolean

source on GitHub