"hithere there" <pyli...@gmail.com> wrote
#! /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)
No idea what viewtable does, never seen it before...
The only case I found on Google was in a tutorial which defined
viewtable() as a function, it wasn't in the pgdb module...
#sys.stdout.write()
This writes nothing to stdout. Apparently successfully from
your comment below.
Try:
sys.stdout.write(str(i))
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?
The print is writing to the console I assume? That is the normal method.
Can anyone point me to a book specificly for pgdb, python and postgre?
It doesn't look lie you need a postgres specific boook but just to
go through the standard Python tutorial. It should make most things clear.
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.
Yes, just define them in a file then import that file as a module.
The standard tutorial explains that too.
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor