Skip to content

Instantly share code, notes, and snippets.

@jasonjohnson
Created May 16, 2014 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonjohnson/6496738e011b495d1910 to your computer and use it in GitHub Desktop.
Save jasonjohnson/6496738e011b495d1910 to your computer and use it in GitHub Desktop.
sketch for simple python database lib?
from nugget import use, bind, find, load, save
# Open a database.
use(":memory:")
# Create a class to bind to a database table.
class Contact(object):
pass
# Associate a class with a database table.
bind(Contact, "contacts")
# Create an object with arbitrary properties.
contact = Contact()
contact.name = "Jason"
contact.email = "jason@example.com"
# Save a Contact.
save(contact)
# Find a list of Contacts.
find(Contact)
find(Contact, "name = ?", "Jason")
# Load a specific Contact.
load(Contact, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment