[Python-de] Indirekter Funktionsaufruf
Oliver Vecernik
vecernik at aon.at
Wed Jan 22 11:21:16 EST 2003
Hallo Leute!
Ich habe in einer Datenbank eine Tabelle mit Funktionsnamen in einem
Textfeld.
mms=# \d imports
Table "imports"
Column | Type | Modifiers
-------------+---------+-----------
func | text | not null
url | text |
last_update | date |
active | boolean |
Primary key: imports_pkey
mms=# select func from imports;
func
---------
iso3166
mab
plzv
(3 rows)
Diese Funktionen sollen der Reihe nach aufgerufen werden:
...
class MMS:
def __init__(self):
self.cx = PgSQL.connect('localhost::mms')
self.cu = self.cx.cursor()
def __del__(self):
self.cu.close()
self.cx.close()
def read_functions(self):
self.cu.execute("SELECT func FROM imports WHERE active = TRUE");
return self.cu.fetchall()
...
def main():
db = MMS()
imports = db.read_functions()
for func in imports:
apply(func)
del db
Leider bekomme ich folgende Fehlermeldung:
>>> ## working on region in file /tmp/python-25645jGA...
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/tmp/python-25645jGA", line 119, in ?
main()
File "/tmp/python-25645jGA", line 115, in main
apply(func)
AttributeError: PgResultSet instance has no __call__ method
Wie muß ich die Funktionen richtig aufrufen?
Schöne Grüße
Oliver
More information about the Python-de
mailing list