~psycopg/psycopg/2.0.x

« back to all changes in this revision

Viewing changes to examples/dict.py

  • Committer: Federico Di Gregorio
  • Date: 2005-06-13 06:25:06 UTC
  • Revision ID: fog-fffb514a007294079bbec1acfbc081157345f9a7
psycopg->psycopg2 switch in the examples.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
## don't modify anything below this line (except for experimenting)
20
20
 
21
21
import sys
22
 
import psycopg
23
 
import psycopg.extras
 
22
import psycopg2
 
23
import psycopg2.extras
24
24
 
25
25
if len(sys.argv) > 1:
26
26
    DSN = sys.argv[1]
27
27
 
28
28
print "Opening connection using dsn:", DSN
29
 
conn = psycopg.connect(DSN)
 
29
conn = psycopg2.connect(DSN)
30
30
print "Encoding for this connection is", conn.encoding
31
31
 
32
32
    
33
 
curs = conn.cursor(cursor_factory=psycopg.extras.DictCursor)
 
33
curs = conn.cursor(cursor_factory=psycopg2.extras.DictCursor)
34
34
curs.execute("SELECT 1 AS foo, 'cip' AS bar, date(now()) as zot")
35
35
 
36
36
data = curs.fetchone()