[Python-Dev] Convert Sqlite Function from cx_Oracle
Carlos Eugenio
cedugenio at gmail.com
Mon Oct 30 15:41:20 EDT 2017
==============================================================
SQLITE3 Function
def get_db():
def dict_factory(cursor, row):
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d
db = getattr(g, '_database', None)
if db is None:
db = g._database = sqlite3.connect(DATABASE)
db.row_factory = dict_factory
return db
================================================================
I try this form but isnt ok . Can I help me ?
import cx_Oracle
con = cx_Oracle.connect('xxxx/xxxx at xxxxxxx/xxxxxxx')
cur = con.cursor()
cur.execute("select * from test")
desc = [d[0] for d in cur.description]
result = [dict(zip(dec,line))for line in cur]
print (result)
cur.close()
--
Carlos Eugênio
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20171030/186f4f41/attachment.html>
More information about the Python-Dev
mailing list