In Django, how to create tables from an SQL file when syncdb is run
Posted
by Sidney
on Stack Overflow
See other posts from Stack Overflow
or by Sidney
Published on 2010-04-13T09:32:04Z
Indexed on
2010/04/13
9:32 UTC
Read the original article
Hit count: 311
Hi, How do I make syncdb execute SQL queries (for table creation) defined by me, rather then generating tables automatically.
I'm looking for this solution as some particular models in my app represent SQL-table-views for a legacy-database table. So, I've created their SQL-views in my django-DB like this:
CREATE VIEW legacy_series AS SELECT * FROM legacy.series;
I have a reverse engineered model that represents the above view/legacytable. But whenever I run syncdb, I have to create all the views first by running sql scripts, otherwise syncdb simply creates tables for them (if a view is not found).
How do I make syncdb run the above mentioned SQL?
© Stack Overflow or respective owner