Python and Db

Gabriel Genellina gagsl-py2 at
Tue Apr 1 04:39:36 CEST 2008

En Mon, 31 Mar 2008 17:50:42 -0300, David Anderson <zerty.david at>  

> I would like to use sqlite, But I also wanted a tutorial with the basis  
> of
> the sql and etc, I never dealed with dbs before

Then any database tutorial covering SQL will do. Of course there are  
differences between different DBMS, but the basics are the same. Once you  
know the SQL sentence you want to execute (e.g. "select name, salary from  
employee order by name") consult the Python docs to see how to actually  
write it:

conn = sqlite3.connect('acme.db')
cursor = conn.cursor()
cursor.execute("select name, salary from employee order by name")
for row in cursor:
     name, salary = row
     print "%20s %8.2f" % (name, salary)

Gabriel Genellina

More information about the Python-list mailing list