butterdb is a library to help you work with Google Spreadsheet data. It lets you model your data as Python objects, to be easily manipulated or created.
How do I use it?
import butterdb import json # For getting OAuth Credential JSON file see http://gspread.readthedocs.org/en/latest/oauth2.html # Ensure that the client_email has been granted privileges to any workbooks you wish to access. with open('SomeGoogleProject-2a31d827b2a9.json') as credentials_file: json_key = json.load(credentials_file) client_email = json_key['client_email'] private_key = str(json_key['private_key']).encode('utf-8') database = butterdb.Database(name="MyDatabaseSheet", client_email=client_email, private_key=private_key) @butterdb.register(database) class User(butterdb.Model): def __init__(self, name, password): self.name = self.field(name) self.password = self.field(password) users = User.get_instances() marianne = users print(marianne.password) # rainbow_trout marianne.password = "hunter2" marianne.commit()
How do I make instances?
bob = User("bob", "BestPassword!") bob.commit()
Where do I get it?
pip install butterdb
Simple as that?
Yep! butterdb is a simple interface around gspread. Just .commit() your objects when you want to update the spreadsheet!
How do I run the tests?
- Store data in Google Spreadsheets (the cloud!!!)
- Models from classes
- Fields as attributes. decimals, ints and strings only (as far as I know)
- Mocked unit tests, mock database
- Arbitrary cell execution with =blah() (free stored procedures?)
- Auto backup/bad patch control
- Spreadsheets must exist before connecting
- Customizable fields
- Customizable table size (arbitrarily hardcoded)
Comments, concerns, issues and pull requests welcomed. Reddit /u/Widdershiny or email me at firstname.lastname@example.org.
MIT License. See LICENSE file for full text.