Metadata-Version: 2.1
Name: fooster-db
Version: 0.10.0
Summary: a human-readable, magic database in Python
Home-page: https://github.com/lilyinstarlight/python-fooster-db
Author: Lily Foster
Author-email: lily@lily.flowers
License: MIT
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Environment :: No Input/Output (Daemon)
Classifier: Intended Audience :: Developers
Classifier: License :: Freely Distributable
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: Implementation
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Database
Classifier: Topic :: Database :: Database Engines/Servers
Classifier: Topic :: Software Development :: Libraries
Description-Content-Type: text/markdown
License-File: LICENSE

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.

```python
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())
```


