|
pycrossword
0.4
Pure-Python implementation of a crossword puzzle generator and editor
|
SQLite database driver implementation wrapping the standard Python sqlite3 methods. More...
Public Member Functions | |
| def | __init__ (self, dbname=None, fullpath=False, recreate=False, connect=True) |
| Constructor initializes DB driver connection. More... | |
| def | __del__ (self) |
| Destructor disconnects from DB. More... | |
| def | setpath (self, dbname, fullpath=False, recreate=False, connect=True) |
| Initializes the path to the DB file and establishes a connection if required. More... | |
| def | connect (self) |
| Connects to the DB file (Sqlitedb::dbpath). More... | |
| def | disconnect (self, commit_trailing=True) |
| Disconnects from the currently open DB. More... | |
| def | create_db (self, overwrite=False) |
| Creates the DB in Sqlitedb::dbpath, optionally overwriting the existing file. More... | |
| def | create_tables (self) |
| Creates the default table structure in the DB. More... | |
| def | get_words (self) |
| def | get_pos (self) |
Public Attributes | |
| dbpath | |
str full path to the DB More... | |
| conn | |
| internal DB connection object (SQLite driver) More... | |
SQLite database driver implementation wrapping the standard Python sqlite3 methods.
Some handy methods are added to connect / disconnect to / from the DB, create / recreate the DB with the default set of tables (to use as a word source), and import Hunspell dictionary data.
| def pycross.dbapi.Sqlitedb.__init__ | ( | self, | |
dbname = None, |
|||
fullpath = False, |
|||
recreate = False, |
|||
connect = True |
|||
| ) |
Constructor initializes DB driver connection.
| dbname | str path to database file (*.db) or an abbreviated language name for preinstalled DB files stored in 'assets/dic', e.g. 'en' (='assets/dic/en.db') |
| def pycross.dbapi.Sqlitedb.__del__ | ( | self | ) |
Destructor disconnects from DB.
| def pycross.dbapi.Sqlitedb.connect | ( | self | ) |
Connects to the DB file (Sqlitedb::dbpath).
bool True on success, False on failure | def pycross.dbapi.Sqlitedb.create_db | ( | self, | |
overwrite = False |
|||
| ) |
Creates the DB in Sqlitedb::dbpath, optionally overwriting the existing file.
| overwrite | bool True to overwrite the existing file (default = False) |
True, all data in the DB file (if present) will be lost! bool True on success, False on failure | def pycross.dbapi.Sqlitedb.create_tables | ( | self | ) |
Creates the default table structure in the DB.
bool True on success, False on failure | def pycross.dbapi.Sqlitedb.disconnect | ( | self, | |
commit_trailing = True |
|||
| ) |
Disconnects from the currently open DB.
| commit_trailing | bool True (default) to commit all pending changes to the DB before disconnecting |
| def pycross.dbapi.Sqlitedb.get_pos | ( | self | ) |
| def pycross.dbapi.Sqlitedb.get_words | ( | self | ) |
| def pycross.dbapi.Sqlitedb.setpath | ( | self, | |
| dbname, | |||
fullpath = False, |
|||
recreate = False, |
|||
connect = True |
|||
| ) |
Initializes the path to the DB file and establishes a connection if required.
| dbname | str path to database file (*.db) or an abbreviated language name - see init() |
| fullpath | bool True to indicate that the 'dbname' argument is the full file path (default = False) |
| recreate | bool True to recreate the database file with the default table structure (default = False). |
True, all data in the DB file (if present) will be lost! | connect | bool True (default) to attempt connecting to the DB immediately |
bool True on success, False on failure | pycross.dbapi.Sqlitedb.conn |
internal DB connection object (SQLite driver)
| pycross.dbapi.Sqlitedb.dbpath |
str full path to the DB
1.8.17