MySQL + Python.
Ingo Linkweiler
i.linkweiler at web.de
Fri Nov 1 07:26:28 EST 2002
This is a simple working example of mySQL.
Now I want to use a "DictCursor". How do I use it, or where do I find it?
c=db.cursor(???DictCursor???) ????
Ingo
# ....................8-<.......................
# A simple mysql-test
# requires a database test, table benutzer, rows (userid, name)
import MySQLdb
db=MySQLdb.connect("localhost","username","password","test")
c=db.cursor()
# insert new item
# c.execute("""INSERT INTO benutzer (userid, name) VALUES (7,"Thomas")""")
# start...
print c.execute("""SELECT * FROM benutzer""")
# get one item
print c.fetchone()
# get all items
print c.fetchall()
print "finished"
More information about the Python-list
mailing list