From: Lennart J. <len...@la...> - 2007-07-03 21:55:31
|
Daniel Cabrera wrote: > Hi, > > Do you know if I can use static o dynamic SQL sentences in Python? > Please could you show me how can I do it? > (sorry for my mail earlier David, didnt realize until now that I did not respond to the list) I'm not sure what you mean by static sql, are you looking for something in python that is similar to sqlj? If that is the case, not that I'm aware of (does not mean that it does not exist though :-). For the dynamic part, is the following snippet of any help? #!/usr/bin/python import DB2 username = 'XXXXXXX' password = 'XXXXXXX' dbname = 'LELLE' conn = DB2.connect(dsn=dbname,uid=username,pwd=password) sql_str = """ select colname from syscat.columns where tabschema = ? and tabname = ? """ c1 = conn.cursor() c1.execute(sql_str, ('SYSIBM','SYSDUMMY1')) for row in c1.fetchall(): print row[0] /Lennart [...] |