At the installation stage of the software (Django bases, of course) I'm
developing, I have to insert data in a database. Is there any easy way to
tell django to execute the SQL directives contained in a .sql file ?
I tried using manage.py but I don't know the good options.
So I would like to do sth like :
./manage.py action file.sql
That is what I was trying to do.
TIA.
the other is to go into mysql and there do:
\. file.sql
You can open a mysql shell with:
manage.py dbshell
--- Amit
* Tourneur Henry-Nicolas <henry-nicol...@mactelecom.com> [2008-03-25 17:32 +0100]:
I'm not familiar with pgsql, so I don't know why is it asking you for a password. There is a third method for doing what you want, although it is quiet awkward. You can write a simple python/django script, that reads the sql statements from your sql file and execute them using custom sql. It'll probably be slower, especially for large files, than using the db shell, so I wouldn't really recommend it, unless you can justify it somehow.
For custom sql, see:
http://www.djangoproject.com/documentation/model-api/#executing-custom-sql
--- Amit
echo 'SELECT * from app_mytable;' | ./manage.py dbshell
or
cat file.sql | ./manage.py dbshell
--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de