Python/Postgresql help, db.connect()

Jpitzo

Limp Gawd
Joined
May 31, 2002
Messages
453
hello,

I'm in the process of trying to write a python function that does a few simply operations and sorts one list via a column in a database. It works fine when I input test cases via IDLE but for somereason when I create the function in postgres it only gives me back empty strings :confused:

Code:
create or replace function sort_wafers(text[],text) returns text as '

import pgdb
def sort_wafers(wafers,run):
    db = pgdb.connect( user="###",database="#",host="###")
    c = db.cursor()
    c.execute("SELECT wafers.name from wafers where wafers.run=\'%s\' order by wafers.num"%(run))
    rb = c.fetchall()
........
........


I think this part is the culprit. It works fine in IDLE but when I'm in postgres it only returns empty strings, even with the same test cases that were working in IDLE. So....my question is....is there a different way you must access the database from inside postgres in order for it to get the necessary columns?

thanks in advance guys.
 
It looks like you're creating Python stored procedures inside Postgres...

If that's the case, and the function, living inside the DB, is getting called by the database, you probably don't need to connect() to the DB.
 
ameoba said:
It looks like you're creating Python stored procedures inside Postgres...

If that's the case, and the function, living inside the DB, is getting called by the database, you probably don't need to connect() to the DB.

yes, exactly. I think theres something I have to put in place of it...if I just delete the connect command that does nothing for me. I've been trying to work with it all morning with no luck...ick.
 
Back
Top