a human-readable, magic database in Python
Project description
fooster-db
fooster-db is a human-readable, magic database implemented in Python. The database presents a dictionary of first column value to entry and each entry is represented by an object where each column is an attribute. If any attribute of the entry is changed, the database file is automatically updated to represent it. The database is formatted in a human-readable table and can store JSON-serializable data structures. This project is not designed for large amounts of data or when speed is a priority, but when you need, for example, an easy way to store text data or metadata.
Usage
Below is an example for a user database that demonstrates all features of the module.
import fooster.db
users = fooster.db.Database('users.db', ['username', 'password', 'favorite_number', 'admin', 'friends'])
print('Users:')
for user in users:
print(user)
print()
users['test1'] = users.Entry(password='supersecretpassword', favorite_number=None, admin=False, friends=['olduser'])
users['test2'] = fooster.db.Entry('test3', 'correcthorsebatterystaple', 7, False, ['alice', 'bob'])
admin_user = users.add('admin', 'admin|nimda', 1337, True, [])
print('Length: {}\n'.format(len(users)))
test1_user = users['test1']
test1_user.favorite_number = 1
print('User: {} ({}) - {}\n'.format(test1_user.username, test1_user.favorite_number, ', '.join(test1_user.friends)))
test2_user = users.get('test2')
test2_user.admin = True
print('User: {} ({}) - {}\n'.format(test2_user.username, test2_user.favorite_number, ', '.join(test2_user.friends)))
admin_user.friends.append(test2_user.username)
print('Users:')
for user in users:
print(user)
print()
del users['test1']
for user in users:
user.admin = False
print('Usernames:')
for username in users.keys():
print(username)
print()
print('User Dict: {}\n'.format(dict(users['test2'])))
print('User Test: {}\n'.format('test2' in users))
print('User Values: {}\n'.format(users.values()))
users.remove('admin')
print('Users:')
for user in users.values():
print(user)
print()
print('Database:\n')
with open('users.db', 'r') as file:
print(file.read())
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fooster-db-0.10.0.tar.gz.
File metadata
- Download URL: fooster-db-0.10.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55135c29854c6c1cadb6f579590784887a91e11031528bd8c8e51cb7f7394cb3
|
|
| MD5 |
1e772656b0f1ebd61f7fff200c0e8943
|
|
| BLAKE2b-256 |
7c7d5ea0a405ca99f9c8c5475dc4ae5a8599c651fa751df22b7aad30ca4a0680
|
File details
Details for the file fooster_db-0.10.0-py3-none-any.whl.
File metadata
- Download URL: fooster_db-0.10.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0de1b77113851d1dab433465ce673bfdf7e3cf179920acfc173ab24548d3136a
|
|
| MD5 |
929e45f474a6f63b30a8508dfcba3f7b
|
|
| BLAKE2b-256 |
9d651d0d0684dc9398911d7051e6761c353add7e342beb844f6d8c4d88561688
|