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

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

[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.


Lynx friendly