[Zope] using a ZMySQL database connection object in an external method
Frederic Quin
fquin@profile4u.com
Thu, 7 Jun 2001 11:51:46 +0200
Hi,
instead of giving the connection object to python, you can create a new one...
mycon = MySQLdb.Connection( db=mydb, host=myhost, user=myuser, passwd=mypwd )
Then, you can ask for the cursor of the connection object :
mycursor = mycon.cursor()
And execute a query like this :
mycursor.execute( myquery )
raw_datas = mycursor.fetchall()
Finaly, you can close the connection :
mycon.close()
But I wonder if it's really what you need...
Why do you can to access databases from an external method ???
Frederic Quin
##########################################################################
Is there a How-To, or are there some code fragments that will help me
use a ZMySQL (or a psycopg) database connection object in an external
method? Given that mysql_connection is a ZMySQL database connection
object, I expected
mysql_connection.db.select_db('database')
to work. But I got
Error Type: ProgrammingError
Error Value: (2014, "Commands out of sync; You can't run this command now")
Any help is appreciated. cheers, Luby