faqts : Computers : Programming : Languages : Python : Snippets : Databases

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

20 of 24 people (83%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

Connecting to Oracle database

Jul 5th, 2000 10:01
Nathan Wallace, unknown unknown, Hans Nowak, Snippet 202, Raymond Cote


"""
Packages: database
"""
"""
Thanks to the kind response of Alexander Smishlajev who just sent me the
binary 8.0.4 Oracle extensions for Windows, I've gone from completely
clueless to a db data slinger in about half an hour. 
So, commenting from that vast experience.... :}
"""
import DCOracle, oci_, Busys
dbc = DCOracle.Connect('userID/password@hostname');
c = dbc.cursor();
c.execute('select * from sometablename');
for x in c.fetchall():
	print x
dbc.close();
"""
Also remember that fetchall() is not going to be the best solution when
working with large tables. In those cases use fetchone() to return the
next row of a query or fetchmany(howmany) to return chunks of rows.
"""