Skip to main content

creation, access and modification of SQL databases

Project description

folktales

folktales enables the creation, access and modification of SQL databases, with an emphasis on storing dictionaries easily and accessing database tables as pandas DataFrames easily. It also provides template dictionaries suitable for logging. While it can be used with other databases, it is designed currently to be used easily with SQLite3 databases.

folktales might be used in a logging context, whereby a status dictionary, which features a UUID4 identifier and a UTC datetime by default, is updated with program characteristics or other data and then saved to database.

setup

pip install folktales

Sqliteman is a GUI tool that can be used to interact with SQLite3 databases.

apt install sqliteman

examples

create a database

folktales.create_database(filepath = "database.db")

access a database

database = folktales.access_database(filepath = "database.db")

insert a dictionary into a database table

folktales.insert_dictionary_into_database_table(
    dictionary      = {
                      "a": 1,
                      "b": 2
                      },
    table_name      = "data",
    filepath        = "database.db"
)

state dictionaries

A template state dictionary can be created in the following way:

folktales.template_state_dictionary()

This returns a dictionary that features a UUID4 identifier (uuid.uuid4()) and a datetime (datetime.datetime.utcnow()).

A state dictionary can be created at the same time as updating it with an existing dictionary in the following way:

folktales.state_dictionary(
    entries = {
              "state_ID"             : "84f80687-cdd7-48f9-b21c-3d75fd759604",
              "price_recommendation" : 5007.24
              }
)

insert a state dictionary into a database table

folktales.insert_state_dictionary_into_database_table(
    entries    = {
                 "state_ID"             : "84f80687-cdd7-48f9-b21c-3d75fd759604",
                 "price_recommendation" : 5007.24
                 },
    table_name = "do_stocks",
    filepath   = "database.db"
)

access a database table as a pandas DataFrame

df = folktales.DataFrame_of_database_table(
    filepath   = "database.db",
    table_name = "do_stocks"
)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

folktales-2018.5.3.245.tar.gz (3.9 kB view details)

Uploaded Source

File details

Details for the file folktales-2018.5.3.245.tar.gz.

File metadata

File hashes

Hashes for folktales-2018.5.3.245.tar.gz
Algorithm Hash digest
SHA256 88282b476466802cdf270f6c6706e976d60858a7b99e8c565dc2bd49a4a42c84
MD5 8043c04855bea950853011b8bc32ec0b
BLAKE2b-256 f45df0a3d4fd12e827979ff62d195c92f6f3f871a63d20b43afe9faa75120ba3

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page