graphenestorage.sqlite module

class graphenestorage.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.

sqlDataBaseFile = None

Ensure that the directory in which the data is stored exists

class graphenestorage.sqlite.SQLiteStore(*args, **kwargs)

Bases: graphenestorage.sqlite.SQLiteFile, graphenestorage.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