DAL/Postgres not creating a table

255 views
Skip to first unread message

Marek Mollin

unread,
Jul 20, 2012, 5:17:06 PM7/20/12
to web...@googlegroups.com
Hey,
Problem is as follows.
I start a clean db in psql. Test the connection + delete all the /databases files to fresh with remote db.
When I launch index page tables start getting created then I get error regarding some table is missing. I check sql.log and it did not even start creating the table (this + a few more get ommited).

I have check_reserved in my DAL declaration. Table is not ill named:

db.define_table('delivery_type',
 
Field('name','string'),
 
Field('price','double'),
 format
=lambda r: r.name
 
)

but there are others not getting created
version 1.99.7

Bruno Rocha

unread,
Jul 20, 2012, 5:30:00 PM7/20/12
to web...@googlegroups.com

are you sure the migrate is not False in db = DAL(...) ?

try including migrate=True in your define_table

--
 
 
 

Ovidio Marinho

unread,
Jul 20, 2012, 5:34:30 PM7/20/12
to web...@googlegroups.com
Shows the Ticket?

      


       Ovidio Marinho Falcao Neto
                Web Developer
             ovid...@gmail.com 
          ovidio...@itjp.net.br
                 ITJP - itjp.net.br
               83   8826 9088 - Oi
               83   9334 0266 - Claro
                        Brasil
              



2012/7/20 Bruno Rocha <rocha...@gmail.com>
--
 
 
 

Marek Mollin

unread,
Jul 21, 2012, 5:55:10 AM7/21/12
to web...@googlegroups.com
other info:
I am using postgres 9.1

No migrate is not set to false. + it creates all other tables it just stops at certain point and skips a few of them.

error stack:
Traceback (most recent call last):
 
File "G:\mac-backup\CLIENTS 2\paczkon\web2py\gluon\restricted.py", line 205, in restricted
 
exec ccode in environment
 
File "G:/mac-backup/CLIENTS 2/paczkon/web2py/applications/menzo/models/db.py", line 212, in <module>
 format
=lambda r: '%s %s %s' % (r.user.email, r.status, r.price)
 
File "G:\mac-backup\CLIENTS 2\paczkon\web2py\gluon\dal.py", line 6320, in define_table
 polymodel
=polymodel)
 
File "G:\mac-backup\CLIENTS 2\paczkon\web2py\gluon\dal.py", line 719, in create_table
 
self.create_sequence_and_triggers(query,table)
 
File "G:\mac-backup\CLIENTS 2\paczkon\web2py\gluon\dal.py", line 1954, in create_sequence_and_triggers
 
self.execute(query)
 
File "G:\mac-backup\CLIENTS 2\paczkon\web2py\gluon\dal.py", line 1392, in execute
 
return self.log_execute(*a, **b)
 
File "G:\mac-backup\CLIENTS 2\paczkon\web2py\gluon\dal.py", line 1386, in log_execute
 ret
= self.cursor.execute(*a, **b)
ProgrammingError: relation "delivery_type" does not exist

Massimo Di Pierro

unread,
Jul 21, 2012, 10:06:56 AM7/21/12
to web...@googlegroups.com
You have some of type "reference deliverytype" and table "deliverytype" is not defined.

There could be an order issue in the table and postgres cannot alter a table and add or modify a field which is a reference to a table not defined yet.

Niphlod

unread,
Jul 21, 2012, 10:08:29 AM7/21/12
to web...@googlegroups.com
on sql.log in your databases folder there is the excerpt of the statements used to create the table.

I'm guessing that you implemented your app adding here and there tables but never defining them "in order" .

This seems the kind of problem when you try to create a table with foreign keys pointing to a table that doesn't yet exist (i.e. Field('detail_id', db.details) without the db.details be defined already).

Ovidio Marinho

unread,
Jul 21, 2012, 11:50:46 AM7/21/12
to web...@googlegroups.com
What is your OS?
What is your version web2py?
If windows is this the start or web2py.exe web2py.py?
the drive is installed psycopg2?
Have you ever tried to postgres 8.4, makes this test.
      


       Ovidio Marinho Falcao Neto
                Web Developer
             ovid...@gmail.com 
          ovidio...@itjp.net.br
                 ITJP - itjp.net.br
               83   8826 9088 - Oi
               83   9334 0266 - Claro
                        Brasil
              



2012/7/21 Niphlod <nip...@gmail.com>
--
 
 
 

Marek Mollin

unread,
Jul 21, 2012, 2:04:15 PM7/21/12
to web...@googlegroups.com
Again web2py-users doesnt disappoint.
I forgot that opposed to sqlite postgres has strong typing of fields so you have to have existing tables for fk.
(I thought that 'reference table' instead of db.table - overrides that, at the app level it does at least)

I think this should perhaps go to book about db gotchas.
Since most people start rumbling on sqlite and then migrate... worth reminding I guess.

Thanks again.

Massimo Di Pierro

unread,
Jul 21, 2012, 2:18:35 PM7/21/12
to web...@googlegroups.com
I think it is, but it is in the last section of chapter 6.
Reply all
Reply to author
Forward
0 new messages