JSON from Python mysqldb

TYR a.harrowell at gmail.com
Wed Aug 27 09:41:24 EDT 2008


On Aug 27, 2:37 pm, TYR <a.harrow... at gmail.com> wrote:
> There's always the naive option.
>
> query = ('species', 'lifestyle', 'coolness', 'tentacles=>8')
> db.execute('SELECT %s, %s, %s % FROM creatures WHERE %s;' % query)
> record = dict(zip((query), (db.fetchall()))
> array = '''{
>              '''
> for k,v in record:
>   array.append('"(k)":"(v)"')
> array.append('''
>                 }''')

Actually, don't.

query = ('species', 'lifestyle', 'coolness')
limit = ('tentacles=>8')



More information about the Python-list mailing list