[mod_python] SQL question

Luis M. Gonzalez luismg at gmx.net
Wed Feb 1 12:23:24 EST 2006


Thank you all for your responses!
I think Joshua Ginsberg already gave me a solution (off line) to this 
situation as folows:

    db = MySQLdb.connect(user='mysql', db='foo')
    c = db.cursor()
    c.execute('''describe address''')
    t = c.fetchall()
    t
    (('id', 'int(11)', '', 'PRI', None, 'auto_increment'), ('fn',
    'varchar(255)', 'YES', '', None, ''), ('ln', 'varchar(255)', 'YES', '',
    None, ''), ('a1', 'varchar(255)', 'YES', '', None, ''), ('a2',
    'varchar(255)', 'YES', '', None, ''), ('c', 'varchar(255)', 'YES', '',
    None, ''), ('s', 'char(2)', 'YES', '', None, ''), ('zip', 'varchar(9)',
    'YES', '', None, ''))
    >>> filter(lambda x: x[3] == 'PRI', t)[0][0]
    'id'

Nicholas and James:
I'm using MySQLdb and as far as I know, "cursor.description" gives me only a 
seven-item tuple containing name, type code, display size, internal size, 
precision, scale, and nullability.
Actually, I use it to get the three first values in my script.

James:
I'm sending you the script...

Thanks you all and, again, sorry for the question!
I imagined that the script would be of interest to somebody here...

Regards,
Luis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20060201/d0d17a6f/attachment.html


More information about the Mod_python mailing list