I'm using TurboGears-0.8a4 and have a problem when creating the tables from my model. I included a simplified model and the Traceback below.
What can I do to prevent this behaviour? I managed to create the tables one by one, first Patient and then Behandeling, but when I alter the model and want to do a tg-admin sql drop, tg-admin sql create I get the same problem.
model.py :
---------------
from sqlobject import *
from turbogears.database import PackageHub
hub = PackageHub("test")
__connection__ = hub
class Patient(SQLObject):
Behandelingen = MultipleJoin('Behandeling')
Naam = StringCol()
class Behandeling(SQLObject):
Patient = ForeignKey('Patient')
Result from tg-admin sql sql:
---------------------------------------
Using database URI postgres://TurboGears:[EMAIL PROTECTED]/Test
CREATE TABLE behandeling (
id SERIAL PRIMARY KEY,
patient_id INT, CONSTRAINT patient_id_exists FOREIGN KEY (patient_id) REFERENCES patient (id)
);
CREATE TABLE patient (
id SERIAL PRIMARY KEY,
naam TEXT
);
Result from tg-admin sql create :
---------------------------------------------
Using database URI postgres://TurboGears:[EMAIL PROTECTED]/Test
Traceback (most recent call last):
File "C:\Python24\Scripts\tg-admin-script.py", line 7, in ?
sys.exit(
File "c:\python24\lib\site-packages\TurboGears-0.8a4-py2.4.egg\turbogears\command\__init__.py", line 186, in main
command.run()
File "c:\python24\lib\site-packages\TurboGears-0.8a4-py2.4.egg\turbogears\command\__init__.py", line 106, in run
command.the_runner.run(sys.argv)
File "c:\python24\lib\site-packages\SQLObject-
0.7.0-py2.4.egg\sqlobject\manager\command.py", line 102, in run
runner.run()
File "c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\manager\command.py", line 233, in run
self.command()
File "c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\manager\command.py", line 570, in command
soClass.createTable()
File "c:\python24\lib\site-packages\SQLObject-
0.7.0-py2.4.egg\sqlobject\main.py", line 1308, in createTable
conn.createTable(cls)
File "c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\dbconnection.py", line 516, in createTable
self.query(self.createTableSQL(soClass))
File "c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\dbconnection.py", line 303, in query
return self._runWithConnection(self._query, s)
File "c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\dbconnection.py", line 217, in _runWithConnection
val = meth(conn, *args)
File "c:\python24\lib\site-packages\SQLObject-
0.7.0-py2.4.egg\sqlobject\dbconnection.py", line 300, in _query
self._executeRetry(conn, conn.cursor(), s)
File "c:\python24\lib\site-packages\SQLObject-0.7.0-py2.4.egg\sqlobject\dbconnection.py", line 295, in _executeRetry
return cursor.execute(query)
psycopg.ProgrammingError: ERROR: relation "patient" does not exist
CREATE TABLE behandeling (
id SERIAL PRIMARY KEY,
patient_id INT, CONSTRAINT patient_id_exists FOREIGN KEY (patient_id) REFERENCES patient (id)
)
- [TurboGears] Problem with tg-admin sql create Rudy Schockaert
- [TurboGears] Re: Problem with tg-admin sql c... Toke Høiland-Jørgensen
- [TurboGears] Re: Problem with tg-admin s... Ian Bicking
- [TurboGears] Re: Problem with tg-adm... Rudy Schockaert

