Hi, Dmitry
Thank you for a quick response.
It is really helpful for me.
Thanks,
satomi
[EMAIL PROTECTED]
09/10/2007 06:44 PM
To
Satomi Ninomiya/db/[EMAIL PROTECTED]
cc
db-sig@python.org
Subject
Re: [DB-SIG] questions for Python Database API Specification v2.0
Hello Satomi,
> I have a question about Python Database API Specification v2.0.
http://www.python.org/dev/peps/pep-0249/
> I would like to access the database connected by ODBC and am looking for
a sample code for that.
Here I've pasted some simple examples:
-------------------------------------------------------------------
# -*- coding: utf-8 -*-
# Windows only, http://sourceforge.net/projects/pywin32/
import odbc
conn = odbc.odbc('DBALIAS') # or odbc.odbc('DBALIAS/USERNAME/PASSWORD')
cur = conn.cursor()
cur.execute('SELECT * FROM YOURTABLE')
data = cur.fetchall()
print data
##############################
# http://ceodbc.sourceforge.net/
import ceODBC
conn = ceODBC.connect('DSN=DBALIAS') # or
ceODBC.connect('DSN=DBALIAS;UID=USERNAME;PWD=PASSWORD')
cur = conn.cursor()
cur.execute('SELECT * FROM YOURTABLE')
data = cur.fetchall()
print data
##############################
# using Egenix's commercial friver
# www.egenix.com/products/python/mxODBC
import mx.ODBC.Windows as odbc
conn = odbc.connect('DBALIAS') # or odbc.connect('DBALIAS', 'USERNAME',
'PASSWORD')
cur = conn.cursor()
cur.execute('SELECT * FROM YOURTABLE')
data = cur.fetchall()
print data
-------------------------------------------------------------------
--
Best Regards,
Dmitry V. Selitsky
+375 29 7724015 | ICQ 73737480 |
http://wiki.python.org/moin/DmitrySelitsky
---
This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
_______________________________________________
DB-SIG maillist - DB-SIG@python.org
http://mail.python.org/mailman/listinfo/db-sig