Differences between revisions 5 and 6
Revision 5 as of 2007-10-07 02:54:54
Size: 2653
Editor: pool-68-238-14-194
Comment:
Revision 6 as of 2007-10-07 03:00:51
Size: 2640
Editor: pool-68-238-14-194
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
#FORMAT restructuredtext #FORMAT rst
Line 27: Line 27:
------------------ ------------------------------------------------------------------------------------ ================== ====================================================================================
task postgresql
create database createdb mydb
command-line tool psql -d mydb
GUI tool pgadmin3
install module easy_install psycopg2
import from psycopg2 import *
connect conn = connect("dbname='testdb' user='me' host='localhost' password='mypassword'”)
get cursor curs = conn.cursor()
execute SELECT curs.execute('SELECT * FROM tbl')
fetch curs.fetchone(); curs.fetchall(); curs.fetchmany()
use bind variables curs.execute('SELECT * FROM tbl WHERE col = %(varnm)s', {'varnm':22})
commit conn.commit() (required)

DbApiCheatSheet (last edited 2010-03-09 03:54:30 by bb14f857)

Unable to edit the page? See the FrontPage for instructions.