I'm writing a TG site that also requires a few non-web processes to run
in the backend. I want a command-line script to insert some rows in
the database.
This is the gist of what I'm trying to do:
from model import Carrier
from sqlobject import sqlhub, connectionForURI
sqlhub.processConnection =
connectionForURI("postgres://matt:[EMAIL PROTECTED]/matt")
for (carriername, emailgateway, webgateway) in gateways:
Carrier(carriername=carriername, emailgateway=emailgateway)
I tried to import my classes by name from model.py, then create
instances of them to insert rows, but I got this TB:
$ ./load_data.py
Traceback (most recent call last):
File "./load_data.py", line 50, in ?
insert_gateways(gateways)
File "./load_data.py", line 46, in insert_gateways
Carrier(carriername=carriername, emailgateway=emailgateway)
File
"/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/declarative.py",
line 93, in _wrapper
return fn(self, *args, **kwargs)
File
"/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/main.py",
line 1197, in __init__
self._create(id, **kw)
File
"/usr/lib/python2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/main.py",
line 1224, in _create
self._SO_finishCreate(id)
File "/usr/lib/py
thon2.4/site-packages/SQLObject-0.7.1dev_r1860-py2.4.egg/sqlobject/main.py",
line 1247, in _SO_finishCreate
id = self._connection.queryInsertID(self,
File
"/usr/lib/python2.4/site-packages/TurboGears-1.0b1-py2.4.egg/turbogears/database.py",
line 172, in __get__
self.set_hub()
File
"/usr/lib/python2.4/site-packages/TurboGears-1.0b1-py2.4.egg/turbogears/database.py",
line 190, in set_hub
raise KeyError, "No database configuration found!"
KeyError: 'No database configuration found!'
I suspect the problem is related to the line at the top of model.py
that looks like this:
hub = PackageHub("bazman")
__connection__ = hub
What am I doing wrong? What do I need to do to be able to import the
class defined inside model.py?
TIA
Matt
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---