Created
May 16, 2014 01:12
-
-
Save jasonjohnson/6496738e011b495d1910 to your computer and use it in GitHub Desktop.
sketch for simple python database lib?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "[email protected]" | |
# 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