convert tuple to string

Bob Gailer bgailer at alum.rpi.edu
Mon Aug 11 08:29:34 EDT 2003


At 02:55 PM 8/11/2003 +0200, Lukas Kasprowicz wrote:

>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>Hi Folks,
>
>My Proglem is, I get after a query on a mysql database with module MySQLdb a
>tuple but I need this output from database as a string.
>can anybody help?
>
>- -------------- database ---------
>import MySQLdb
>def select(fields, tables, where):
>   db=MySQLdb.connect(host=db_host,user=db_user,passwd=db_passwd,db=db_db)
>   c = db.cursor()
>   c.execute("SELECT %s FROM %s WHERE %s" %(fields,tables,where))
>   return c.fetchall()
>   db.close()
>
>
>OUTPUT:
>- --------------
>(('6610 at 8210',), ('akku',), ('cover',), ('ladekabel',), ('kfz',),
>('tischladestation',), ('dummy',), ('Hansytasche',), ('poster',), ('o2',),
>('Vodafone',), ('T-Mobile',), ('D1',), ('D2',), ('E+',), ('Eplus',),
>('tasche',), ('zubeh\xf6r',), ('Quertasche',), ('Ledertasche',), ('Boom',),
>('BELEUCHTUNG',), ('Tastaturmatte',), ('Dummys',), ('Zubeh\xf6rset',),
>('TASTATUR',), ('Tastatur',), ('Mittelgeh\xe4use',), ('fast',),
>('Displayschutzfolie',), ('Radio',), ('Tischlader',),
>('Geh\xe4use\xf6ffner',), ('Oberschale',), ('1 Woche',), ('Alubox',),
>('Echtledertasche',), ('E Plus',), ('E+',), ('Eplus',))

There are numerous ways to create strings. It'd help if you'd tell us what 
this string should look like. Either give us an example or a specification.

Bob Gailer
bgailer at alum.rpi.edu
303 442 2625
-------------- next part --------------

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.506 / Virus Database: 303 - Release Date: 8/1/2003


More information about the Python-list mailing list