The pyperl dist provide an interface to the Perl DBI (dbi.py). This allow direct access to all the perl supported databases from python. Full documentation of the API from 'perldoc DBI' or the ORA "Programming the Perl DBI" book, by A. Descartes and T. Bunce.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | dbh = dbi.connect("DBI:mysql:database=mydatabase", "myysername",
RaiseError = 1,
PrintError = 0,
AutoCommit = 1,
)
try:
dbh["AutoCommit"] = 0
except:
print "Can't turn off AutoCommit"
sth = dbh.prepare("select * from foo limit 5")
sth.execute()
while 1:
row = sth.fetchrow_tuple()
if not row: break
print row
dbh.disconnect()
|
Tags: database
Import? Isn't this incomplete? Doesn't it need at least one Import statement? What exactly needs to be imported?
Assuming you need to import dbi.py, and supposing you are using the PythonWin packages (e.g. with ActivePython), how do you import dbi.py instead of dbi.dll? (And assuming you solve that, how can you still import dbi.dll when that is what you want?)
Clyde Adams III