butterdb is a Python object mapper for Google Drive Spreadsheets. Still in development, but usable.
Python
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
butterdb Implement gspread OAuth2 connection May 27, 2015
docs Renamed project to butterdb Apr 7, 2014
tests Fix a typo in get_instances that broke modifying fields Aug 5, 2014
.gitignore Initial commit Dec 10, 2013
.travis.yml Removed 3.3 testing from travis.yml until gspread support for 3.3 Jan 2, 2014
HISTORY.rst Bump version to 0.1.5 Jun 12, 2015
LICENSE
MANIFEST.in Added history.rst, included in setup.py and manifest Mar 7, 2014
README.rst Update README.rst Jun 4, 2015
requirements.txt Implement gspread OAuth2 connection May 27, 2015
setup.cfg Added setup.py for packaging, and tox buiilds Mar 7, 2014
setup.py Bump version to 0.1.5 Jun 12, 2015
tox.ini Added setup.py for packaging, and tox buiilds Mar 7, 2014

README.rst

butterdb

Master: Build Status Master
Develop: Build Status Develop

Documentation | butterdb on PyPi

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?

http://i.imgur.com/h75z1k6.png

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[1]

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?

nosetests

What works?

  • Store data in Google Spreadsheets (the cloud!!!)
  • Models from classes
  • Fields as attributes. decimals, ints and strings only (as far as I know)
  • Commits
  • Mocked unit tests, mock database
  • Arbitrary cell execution with =blah() (free stored procedures?)
  • Auto backup/bad patch control

What's missing?

  • Spreadsheets must exist before connecting
  • References
  • Collections
  • Customizable fields
  • Customizable table size (arbitrarily hardcoded)

Feedback

Comments, concerns, issues and pull requests welcomed. Reddit /u/Widdershiny or email me at ncwjohnstone@gmail.com.

License

MIT License. See LICENSE file for full text.