drop table cascade

145 views
Skip to first unread message

Baron

unread,
Feb 3, 2009, 10:01:44 PM2/3/09
to web2py Web Framework
When I try to drop or truncate a table I get this error:

ProgrammingError: cannot drop table dump because other objects depend
on it
HINT: Use DROP ... CASCADE to drop the dependent objects too.

Deleting from the table works fine because the deletions cascade. Is
there a way to truncate or drop tables through the DAL that have
foreign key dependencies?

Baron

mdipierro

unread,
Feb 3, 2009, 11:28:54 PM2/3/09
to web2py Web Framework
sorry, for now you have to do it manually

db.executesql('DROP TABLE tablename CASCADE;')

perhaps I can add an option to drop/truncate.

Massimo

Baron

unread,
Feb 4, 2009, 12:40:47 AM2/4/09
to web2py Web Framework
thanks Massimo.

mdipierro

unread,
Feb 4, 2009, 1:17:14 AM2/4/09
to web2py Web Framework
give this a try. In trunk

db.table.drop('cascade')

Massimo Di Pierro

unread,
Jan 8, 2013, 12:35:43 PM1/8/13
to web...@googlegroups.com
What do you get? An error? What error?

On Friday, January 4, 2013 3:18:32 AM UTC-6, Liang wrote:
drop('cascade') seems not working.

Liang Yi Aris

unread,
Jan 8, 2013, 9:14:23 PM1/8/13
to web...@googlegroups.com
No error shown in the interactive shell after executing the command. But the tables in the database are still there. I use Postgresql 9.2.

--
 
 
 

Massimo Di Pierro

unread,
Jan 9, 2013, 10:13:46 AM1/9/13
to web...@googlegroups.com
Did you do db.commit() after the db.table.drop()?
Reply all
Reply to author
Forward
0 new messages