Re: convert tuple to string

Discussion in 'Python' started by Bob Gailer, Aug 11, 2003.

  1. Bob Gailer

    Bob Gailer Guest

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

    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
     
    Bob Gailer, Aug 11, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Michal Mikolajczyk
    Replies:
    1
    Views:
    811
    Larry Bates
    Apr 20, 2004
  2. Jeff Epler
    Replies:
    0
    Views:
    960
    Jeff Epler
    Apr 20, 2004
  3. Bill Scherer
    Replies:
    0
    Views:
    615
    Bill Scherer
    Apr 20, 2004
  4. Gregor Horvath

    Why tuple with one item is no tuple

    Gregor Horvath, Mar 15, 2005, in forum: Python
    Replies:
    37
    Views:
    824
    Antoon Pardon
    Mar 30, 2005
  5. Steve
    Replies:
    1
    Views:
    970
    Fredrik Lundh
    Dec 13, 2005
Loading...

Share This Page