Python Database Scripts
jegenye2001
jegenye2001 at gmail.com
Mon Sep 12 12:03:01 EDT 2005
import MySQLdb
# Create a connection object and create a cursor
conn = MySQLdb.Connect(host="localhost", port=3306, user="mysql",
passwd="pwd123", db="mytest")
c = conn.cursor()
# execute some SQL
c.execute("SELECT * FROM mystuff")
# Fetch all results from the cursor into a sequence
results = c.fetchall()
for r in results:
do_something(r)
# close the connection
conn.close()
Cheers,
Miklos
--
Software development: Python,Zope,Plone,PDF,XML,MivaScript
http://www.jegenye.com
More information about the Python-list
mailing list