convert tuple to string

Lukas Kasprowicz nospam at maniacxs.de
Mon Aug 11 14:55:31 CEST 2003


-----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',))


greetz Lukas
- -- 
- ---------------------------------------------------------
Das einzige Mittel gegen Aberglauben ist Wissenschaft.
(Henry Thomas Buckle)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)

iD8DBQE/N5JKHNh65/SR0v0RAmDIAKCUUcd4FuXI9t7g8aU7Mt5nDQaTyQCgoeoN
3yqqMGuLMvWLNgUNDjJk6lY=
=LRtn
-----END PGP SIGNATURE-----




More information about the Python-list mailing list