[Python-Dev] Convert Sqlite Function from cx_Oracle
Carlos Eugenio
cedugenio at gmail.com
Mon Oct 30 15:41:20 EDT 2017
More information about the Python-Dev mailing list
Mon Oct 30 15:41:20 EDT 2017
- Previous message (by thread): [Python-Dev] The type of the result of the copy() method
- Next message (by thread): [Python-Dev] Convert Sqlite Function from cx_Oracle
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
==============================================================
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>
- Previous message (by thread): [Python-Dev] The type of the result of the copy() method
- Next message (by thread): [Python-Dev] Convert Sqlite Function from cx_Oracle
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list