mardi 12 août 2014

python - Postgres différents utilisateurs pour syncdb/migrations et accès de la base de données générale dans Django - Stack Overflow


I'm using Django 1.6 with PostgreSQL and I want to use a two different Postgres users - one for creating the initial tables (syncdb) and performing migrations, and one for general access to the database in my application. Is there a way of doing this?




From ./manage.py help syncdb:



--database=DATABASE Nominates a database to synchronize. Defaults to the "default" database.



You can add another database definition in your DATABASES configuration, and run ./manage.py syncdb --database=name_of_database_definition. You might want to create a small wrapper script for running that command, so that you don't have to type out the --database=... parameter by hand every time.


south also supports that option, so you can also use it to specify the database for your migrations.



I'm using Django 1.6 with PostgreSQL and I want to use a two different Postgres users - one for creating the initial tables (syncdb) and performing migrations, and one for general access to the database in my application. Is there a way of doing this?



From ./manage.py help syncdb:



--database=DATABASE Nominates a database to synchronize. Defaults to the "default" database.



You can add another database definition in your DATABASES configuration, and run ./manage.py syncdb --database=name_of_database_definition. You might want to create a small wrapper script for running that command, so that you don't have to type out the --database=... parameter by hand every time.


south also supports that option, so you can also use it to specify the database for your migrations.


0 commentaires:

Enregistrer un commentaire