Difference between revisions of "Python DBI"
Jump to navigation
Jump to search
PeterHarding (talk | contribs) (New page: <pre> #!/usr/bin/env python import dbi dbh = dbi.connect("DBI:mysql:database=mydatabase", "myysername", RaiseError = 1, PrintError = 0, ...) |
PeterHarding (talk | contribs) |
||
| Line 24: | Line 24: | ||
dbh.disconnect() | dbh.disconnect() | ||
</pre> | </pre> | ||
[[Category:Python]] | [[Category:Python]] | ||
[[Category:DBI]] | [[Category:DBI]] | ||
Revision as of 18:12, 24 May 2008
#!/usr/bin/env python
import dbi
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()