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



On Tue, 2003-05-13 at 11:09, Neil Stone wrote:
> 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..
> 

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

I can't claim to know any python, but this sounds suspiciously like
something that got me in PHP recently so I'll give it a go.

Isn't r is probably going to be returning a list(==array), though with
only 1 element, so you would have to access it as r[1]. At the moment 
it looks like you are treating it as a string  and its returning its
internal reference. 

I've got the O'Reilly Learning Python book here, which I'm not using, if
you want to borrow it - especially if you can swap it for any good php
or MySQL books.

Paul M.   

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

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


Lynx friendly