Entry
How do i connect to a database in Unix using python
Aug 13th, 2001 14:24
Christopher Arndt, Asfar Sayeed,
For this purpose, we have the Python Database API Specification 2.0
For general information see http://www.python.org/sigs/db-sig/
There are a whole bunch of modules for specific database systems that
conform to this specification (or version 1.0 thereof)
For a list see http://www.python.org/topics/database/modules.html
In short, you use them like this:
import dbmodule
cnx = dbmodule.connect(database='test') # there are a lot more
# parameters possible
cur = cnx.cursor()
cur.execute('SELECT * from table')
result_list = cur.fetchall()
# You now have a list of ros in result_list
cur.close()