After i have been trying to fix this for myself for some time now i think i 
have to post this. Here maybe someone can help me.
I have a an Application that works perfectly with SQLite on my local 
machine and on the server. Now i am trying to switch to postgres for 
further testing. I am using a fresh Database.
This is the Database model in db_tables.py:


db.define_table('leader',
>     Field('gender', requires=IS_IN_SET(['maennlich', 'weiblich', 
> 'sonstige'])),
>     Field('sn', notnull=True),
>     Field('cn', notnull=True),
>     Field('bdate', 'date'),
>     Field('street'),
>     Field('plz', 'integer'),
>     Field('place'),
>     Field('phone'),
>     Field('fax'),
>     Field('mobile'),
>     Field('mail', requires=IS_EMAIL()),
>     Field('comment', 'text'))
>
> db.define_table('customer',
>     Field('gender', requires=IS_IN_SET(['maennlich', 'weiblich', 
> 'sonstige'])),
>     Field('sn', notnull=True),
>     Field('cn', notnull=True),
>     Field('number', notnull=True,unique=True,length=255),
>     Field('bdate', 'date'),
>     Field('street'),
>     Field('plz', 'integer'),
>     Field('place'),
>     Field('phone'),
>     Field('fax'),
>     Field('mobile'),
>     Field('mail', requires=IS_EMAIL()),
>     Field('comment', 'text'))
>     #Field.Virtual('full_name', lambda row: row.customer.sn + ' ' + 
> row.customer.cn)) 
>
> db.define_table('course',
>     Field('type', notnull=True),
>     Field('title', notnull=True),
>     Field('day', requires=IS_IN_SET(['Mo', 'Di', 'Mi', 'Do' , 'Fr', 'Sa', 
> 'So'])),
>     Field('time'),
>     Field('max_user', 'integer', notnull=True),    
>     Field('descr', 'text'),
>     Field('start', 'date'),
>     Field('comment', 'text'),
>     Field('sessions', 'integer'),
>     Field('lengh', 'double'),
>     Field('cost', 'double'),    
>     Field('cost_low', 'double'),
>     Field('number', 'integer'),
>     Field('Location'),
>     Field('hon', 'double'))
>     
>
> db.define_table('r_customer_course',
>      Field('customer_id', 'reference customer'),
>      Field('course_id', 'reference course'),
>      Field('took_part', 'boolean'),
>      Field('is_reduced', 'boolean'))
>     
> db.define_table('r_leader_course',
>      Field('leader_id', 'reference leader'),
>      Field('course_id', 'reference course'))
>
>
>
>
As you can see there are references between the Tables. In the table 
r_customer_course and r_leader_course.
When i try to access my application after switching to postgres i get an 
SQL Error in the Errorlog:
 

> '<class \'gluon.contrib.pg8000.errors.ProgrammingError\'> (\'ERROR\', 
> \'42P01\', \'relation "customer" does not exist\')'
>

As you can see there is a Problem with the relation. The  
postgresql-sat.log file gives more details:

ERROR:  relation "customer" does not exist
> STATEMENT:  CREATE TABLE r_customer_course(
>         id SERIAL PRIMARY KEY,
>         customer_id INTEGER REFERENCES customer (id) ON DELETE CASCADE,
>         course_id INTEGER REFERENCES course (id) ON DELETE CASCADE,
>         took_part CHAR(1),
>         is_reduced CHAR(1)
>     );
>

This is really weird. Apparently web2py tries to create the Table with the 
relations first. I dont really understand this behavior by Web2Py. 

Does anyone have a clue how to solve this issue?
Can i "trigger" web2py to initialize the database by simply applying the 
db_tables.py script line by line from start to end?

Thanks in advance!

regards
malte k.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to