Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Re: convert tuple to string

Reply
Thread Tools

Re: convert tuple to string

 
 
Bob Gailer
Guest
Posts: n/a
 
      08-11-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,passw d=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@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
http://www.velocityreviews.com/forums/(E-Mail Removed)
303 442 2625


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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
*tuple vs tuple example print os.path.join(os.path.dirname(os.tmpnam()),*("a","b","c")) Steve Python 1 12-13-2005 10:25 PM
Why tuple with one item is no tuple Gregor Horvath Python 37 03-30-2005 06:58 AM
Easily convert unicode tuple to python string tuple??? Michal Mikolajczyk Python 1 04-20-2004 08:37 PM
Re: Easily convert unicode tuple to python string tuple??? Jeff Epler Python 0 04-20-2004 03:36 PM
Re: Easily convert unicode tuple to python string tuple??? Bill Scherer Python 0 04-20-2004 03:34 PM



Advertisments