D&C Lug - Home Page
Devon & Cornwall Linux Users' Group

[ Date Index ][ Thread Index ]
[ <= Previous by date / thread ] [ Next by date / thread => ]

RE: [LUG] Python Question....



I don't know this particular interface, but it looks like 'r' is a
reference/object.  You will need to call a method on it it get a value, try
printing f.fetch_row().

Clive

-----Original Message-----
From: Neil Stone
To: list@xxxxxxxxxxxx
Sent: 13/05/03 11:09
Subject: [LUG] Python Question....

I have a question relating to python...

I am trying to query a MySQL database and get the result in a readable 
format for me to be able to process...

python code below..

------------

import _mysql
import sys
import os

UserName = os.environ['USER']

# Connect to the MySQL database
db=_mysql.connect(host="localhost",user="<username>",passwd="<password>"
,db="<dbname>")

db.query("""SELECT UserID FROM tblUsers WHERE UserName = `" + RoomName +

"`""")
r=db.store_result()
r.fetch_row()

-------------

The above code returns the UserID field, as it should, but if I tell 
python to "print r" I get "<result object at 811c588>" or similar.

How can I get the UserID (no, not the linux uid) in to a format that i 
can simply print out to the screen and do other work with later on ?

Neil (Man what not knows python...)


--
The Mailing List for the Devon & Cornwall LUG
Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the
message body to unsubscribe.

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

--
The Mailing List for the Devon & Cornwall LUG
Mail majordomo@xxxxxxxxxxxx with "unsubscribe list" in the
message body to unsubscribe.


Lynx friendly