[Tutor] pgdb and console output
hithere there
pylist1 at gmail.com
Sun Mar 7 22:09:41 CET 2010
OS = RHEL 5.4 32Bit
Python = 2.4.3
#! /usr/bin/env python
import pgdb, sys
db = pgdb.connect (dsn='192.168.0.1:familydata',
user='postgres', password='')
cursor = db.cursor ()
cursor.execute ("select * from names")
rows = cursor.fetchall ()
for i in (rows):
print i
#viewtable (db)
#sys.stdout.write()
cursor.close ()
###########END########
The code as is will display the data to the console. I have read the
db API 2.0 at python.org. The problem is viewtable (db) will not work
or sys.stdout.write () to write the table data to the console screen.
What am I doing wrong here or what do I need to do different?
Can anyone point me to a book specificly for pgdb, python and postgre?
Last thing is can I define the classes in a separate files and
reference them? Kinda like code reuse in .Net? I new to Python so
bear with me.
More information about the Tutor
mailing list