Difference between revisions of "Python DBI"

From PeformIQ Upgrade
Jump to navigation Jump to search
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
=Links=
=Links=
* http://www.linuxforu.com/teach-me/database-programming-in-python/


==DBI==
==DBI==
Line 5: Line 7:
* http://www.oreillynet.com/oracle/os_dir/library.csp
* http://www.oreillynet.com/oracle/os_dir/library.csp


=DBD==
==DBD==
 
==ODBC==
 
* http://www.easysoft.com/developer/languages/python/pyodbc.html


==Oracle==
==Oracle==
Line 16: Line 22:


* http://www.sapdb.org/sapdbapi.html
* http://www.sapdb.org/sapdbapi.html
* http://flabellum.org/7.4/sapdbapi.html
=Exmples=
=Exmples=



Latest revision as of 16:55, 28 August 2009

Links

DBI

DBD

ODBC

Oracle

SAP DB

Exmples

#!/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()