mkpreview package¶
Submodules¶
mkpreview.config module¶
Created on Jan 9, 2020
@author: colin bitterfield
A list of common definitions
mkpreview.database module¶
A database class to help with managing SQLite databases
-
class
mkpreview.database.
Database
(database, **kwargs)[source]¶ Bases:
object
Database class provides a higher level connector to SQLite3 It provides methods for:
Usage: myDB = Database(‘/tmp/filename.db’)
Methods: create() : Creates a Database or tests existence of database
: Allows the database to be backed up if it exists.name() : Returns the current database filename. Flag is true if the database exist connect() : Connects this class to the initialized database close() : Commits and Closes the current connection createTable() : Creates a table from a dictionary and adds primary indexes
: Allows overwrite (drop the data in the table)- insertORupdate(): Allows for an insert if not there and an update if there.
- : Uses a dictionary. Checks dictionary against columns to avoid errors
isTable() : Returns True if the tables exists backupTable() : Makes a copy of the table and renames it with a current timestamp dropTable() : Remove all of the data from the table sqlExecute() : Executes an arbitrary SQL Script against the open database. deleteData() : removes database based on table and where.
Variables: global DEBUG : Used for output global QUIET : User for output local message : Return Message for all methods local data(dict): A dictionary for method use. local flag : True / False for results of method self.database : database name for all methods self.method : calling method name self.class : name of the class being called self.db_connect : name of the connection
Returns: All methods return a [True | False] and a message If bad values are passed, it will fast fail and return a message. No further evaluations are made.
-
create
(**kwargs)[source]¶ overwrite = [True | False] backup = [True | False]
If database exists, with overwrite FALSE and backup FALSE, method exists with False If database does not exist it is created If database exists and overwrite without backup, it is deleted If database exists and backup is set, database will be backed up; regardless of overwrite.
FLAG = True if a database is created, False if a database is not created. MESSAGE = database name + actions taken
-
create_table
(**kwargs)[source]¶ create a table, optional drop if exists (default) If overwrite set to false, table will error if it exists
-
data
= {}¶
-
flag
= False¶
-
insert_update
(**kwargs)[source]¶ Insert a row or update the row with the field names in a dictionary parameters: ———– table = Table Name key_field = Field for initial update and where value key_value = Where Value data = Data to update
-
message
= ''¶
mkpreview.mkpreview module¶
mkpreview.version module¶
version string
Module contents¶
__init__ for mkpreview.