-
-
Save cloverstd/7055170 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 torndb import Connection | |
db = Connection('/tmp/mysql.sock', 'research', user='root', password='root') | |
# Official doc: http://torndb.readthedocs.org/en/latest/ | |
# Retreive one object | |
post = db.get("SELECT * FROM posts LIMIT 1") | |
# Retreive several objects | |
for post in db.query("SELECT * FROM posts"): | |
print post.title | |
# INSERT | |
db.execute("INSERT INTO posts (user_id, content) VALUES (%s, %s)", 12, "hello world !") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment