* Tourneur Henry-Nicolas <[EMAIL PROTECTED]> [2008-03-27 08:27 +0100]:
> 
> On Wednesday 26 March 2008 17:25:18 Amit Ramon wrote:
> > You can do that easily enough without django...
> > one way is to do:
> > mysql -u<user> -p<password> <database> < file.sql
> >
> > the other is to go into mysql and there do:
> > \. file.sql
> >
> > You can open a mysql shell with:
> > manage.py dbshell
> >
> >
> I prefer the second way because I have to stay database independant.
> The problem is (with pgsql at least) that when I type manage.py dbshell it 
> asks me for the password even if the password is present in me settings.py.

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






> > --- Amit
> >
> > * Tourneur Henry-Nicolas <[EMAIL PROTECTED]> [2008-03-25 
> 17:32 +0100]:
> > > Hello,
> > >
> > > 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.
> >
> > 
> 
> 
> 

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to