On 05-10-2010 17:36, Mariano Reingart wrote:
> On Tue, Oct 5, 2010 at 10:49 AM, Stef Mientki <[email protected]> wrote:
>> On 05-10-2010 01:10, Mariano Reingart wrote:
>>> Hi, attached is a PostgreSQL enhanced versión of Alexandre Andrade mysql
>>> script.
>>>
>>> It uses information_schema (ANSI Standard), so it might support others
>>> databases too.
>>> It connects to live databases (doesn't need SQL dump), and supports:
>>> keyed tables, most data types, default values, constraints (unique/not
>>> null/referential fk) and comments.
>>>
>> Is it not necessary to put "cur.close() before return succesfull ?
>> cheers,
>> Stef
>>
>> def query(conn, sql,*args):
>> "Execute a SQL query and return rows as a list of dicts"
>> cur = conn.cursor()
>> ret = []
>> try:
>> if DEBUG: print >> sys.stderr, "QUERY: ", sql % args
>> cur.execute(sql, args)
>> for row in cur:
>> dic = {}
>> for i, value in enumerate(row):
>> field = cur.description[i][0]
>> dic[field] = value
>> if DEBUG: print >> sys.stderr, "RET: ", dic
>> ret.append(dic)
>> cur.close () ??
>> return ret
>> finally:
>> cur.close()
>>
> cur.close is at finally clause (it always gets executed)
didn't know that ...
,,, unitl now.
Thanks,
cheers,
Stef
> Best regards,
>
> Mariano Reingart
> http://www.sistemasagiles.com.ar
> http://reingart.blogspot.com