[DB-SIG] questions for Python Database API Specification v2.0

Satomi Ninomiya satomi.ninomiya at db.com
Mon Sep 10 12:00:07 CEST 2007


Hi,  Dmitry

Thank you for a quick response. 
It is really helpful for me.

Thanks,
satomi



d.v.selitsky at gmail.com 
09/10/2007 06:44 PM

To
Satomi Ninomiya/db/dbcom at DBAPAC
cc
db-sig at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/db-sig/attachments/20070910/e58f1321/attachment.htm 


More information about the DB-SIG mailing list