beemstorage.sqlite¶
-
class
beemstorage.sqlite.
SQLiteCommon
¶ Bases:
object
This class abstracts away common sqlite3 operations.
This class should not be used directly.
When inheriting from this class, the following instance members must be defined:
sqlite_file
: Path to the SQLite Database file
-
sql_execute
(query, lastid=False)¶
-
sql_fetchall
(query)¶
-
sql_fetchone
(query)¶
-
class
beemstorage.sqlite.
SQLiteFile
(*args, **kwargs)¶ Bases:
object
This class ensures that the user’s data is stored in its OS preotected user directory:
OSX:
- ~/Library/Application Support/<AppName>
Windows:
- C:Documents and Settings<User>Application DataLocal Settings<AppAuthor><AppName>
- C:Documents and Settings<User>Application Data<AppAuthor><AppName>
Linux:
- ~/.local/share/<AppName>
Furthermore, it offers an interface to generated backups in the backups/ directory every now and then.
Note
The file name can be overwritten when providing a keyword argument
profile
.-
clean_data
(backupdir='backups')¶ Delete files older than 70 days
-
recover_with_latest_backup
(backupdir='backups')¶ Replace database with latest backup
-
refreshBackup
()¶ Make a new backup
-
sqlite3_backup
(backupdir)¶ Create timestamped database copy
-
sqlite3_copy
(src, dst)¶ Copy sql file from src to dst
-
sqlite_file
= None¶ Ensure that the directory in which the data is stored exists
-
class
beemstorage.sqlite.
SQLiteStore
(*args, **kwargs)¶ Bases:
beemstorage.sqlite.SQLiteFile
,beemstorage.sqlite.SQLiteCommon
,beemstorage.interfaces.StoreInterface
The SQLiteStore deals with the sqlite3 part of storing data into a database file.
Note
This module is limited to two columns and merely stores key/value pairs into the sqlite database
On first launch, the database file as well as the tables are created automatically.
When inheriting from this class, the following three class members must be defined:
__tablename__
: Name of the table__key__
: Name of the key column__value__
: Name of the value column
-
create
()¶ Create the new table in the SQLite database
-
delete
(key)¶ Delete a key from the store
Parameters: value (str) – Value
-
exists
()¶ Check if the database table exists
-
get
(key, default=None)¶ Return the key if exists or a default value
Parameters: - value (str) – Value
- default (str) – Default value if key not present
-
items
()¶ returns all items off the store as tuples
-
keys
() → a set-like object providing a view on D's keys¶
-
wipe
()¶ Wipe the store