A database interface that mimics a python dictionary.
Project description
A database interface that acts like a python dictionary
Install
pip install dictabase
Example
Click here to see a complete example main.py
Create a new table
# Create a table representing users from dictabase import BaseDictabaseTable class UserClass(BaseDictabaseTable): pass newUser = New(UserClass, name='Grant', age=31) newUser = New(UserClass, name='Bob', age=99) # there is now a sqlite database containing the 2 users. Yup, thats it!
Look up items in the database
from dictabase import FindOne, FindAll allUsers = FindAll(UserClass) # allUsers is an iterable of all the UserClass objects that exists in the database print('allUsers=', list(allUsers)) >> allUsers= [<UserClass: name='Grant', age=31>, <UserClass: name='Bob', age=99>] user = FindOne(UserClass, name='Grant') print('user=', user) >>user= <UserClass: name='Grant', age=31> user = FindOne(UserClass, name='NotARealName') print('user=', user) >>user= None
Read/Write to the database
# find an object that was previously put in the database user = FindOne(UserClass, name='Grant') # increment the age of the user by 1 user['age'] += 1 # Thats it! the database has now been updated with the new age
Drop a table
from dictabase import Drop Drop(UserClass, confirm=True) # the table has been removed from the database
Delete a specific row in a table
from dictabase import Delete # find an object that was previously put in the database user = FindOne(UserClass, name='Grant') Delete(user) # the user has been removed from the database
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Dictabase-2.0.0.tar.gz
(5.7 kB
view hashes)
Built Distribution
Close
Hashes for Dictabase-2.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e90802065eccac11b905d8618d25986f0908ec7b37cbd67fb80ac99a7af97294 |
|
MD5 | 4a09c2fd61deddd6f3a1af65e78db816 |
|
BLAKE2b-256 | b7be19dc6a1eef0e47ff610c5db75b957048d438458f5cf8416e6b2d657e2a46 |