create create of database of a particular name

Started by Chris Withersabout 10 years ago4 messagesgeneral
Jump to latest
#1Chris Withers
chris@simplistix.co.uk

Hi All,

Django, a popular python web framework, runs its unit tests by creating
a 'test_'-prefixed database and then dropping it at the end of the test run.

Is there any way I can grant a user in postgres the ability only to
create a database of a particular name?

cheers,

Chris

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#2Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Chris Withers (#1)
Re: create create of database of a particular name

On 03/09/2016 05:49 AM, Chris Withers wrote:

Hi All,

Django, a popular python web framework, runs its unit tests by creating
a 'test_'-prefixed database and then dropping it at the end of the test
run.

FYI in Django 1.8+ you can prevent that:

https://docs.djangoproject.com/en/1.8/topics/testing/overview/#the-test-database

" New in Django 1.8:

You can prevent the test databases from being destroyed by adding the
--keepdb flag to the test command. This will preserve the test database
between runs. If the database does not exist, it will first be created.
Any migrations will also be applied in order to keep it up to date.
"

Is there any way I can grant a user in postgres the ability only to
create a database of a particular name?

Not that I know of.

cheers,

Chris

--
Adrian Klaver
adrian.klaver@aklaver.com

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Chris Withers
chris@simplistix.co.uk
In reply to: Adrian Klaver (#2)
Re: create create of database of a particular name

On 09/03/2016 14:53, Adrian Klaver wrote:

On 03/09/2016 05:49 AM, Chris Withers wrote:

Hi All,

Django, a popular python web framework, runs its unit tests by creating
a 'test_'-prefixed database and then dropping it at the end of the test
run.

FYI in Django 1.8+ you can prevent that:

https://docs.djangoproject.com/en/1.8/topics/testing/overview/#the-test-database

" New in Django 1.8:

You can prevent the test databases from being destroyed by adding the
--keepdb flag to the test command. This will preserve the test database
between runs. If the database does not exist, it will first be created.
Any migrations will also be applied in order to keep it up to date.
"

...and we're on 1.7 :-(

Chris

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#4Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Chris Withers (#3)
Re: create create of database of a particular name

On 03/09/2016 07:02 AM, Chris Withers wrote:

On 09/03/2016 14:53, Adrian Klaver wrote:

On 03/09/2016 05:49 AM, Chris Withers wrote:

Hi All,

Django, a popular python web framework, runs its unit tests by creating
a 'test_'-prefixed database and then dropping it at the end of the test
run.

FYI in Django 1.8+ you can prevent that:

https://docs.djangoproject.com/en/1.8/topics/testing/overview/#the-test-database

" New in Django 1.8:

You can prevent the test databases from being destroyed by adding the
--keepdb flag to the test command. This will preserve the test database
between runs. If the database does not exist, it will first be created.
Any migrations will also be applied in order to keep it up to date.
"

...and we're on 1.7 :-(

Then you might want to try what I use, pytest-django:

https://pypi.python.org/pypi/pytest-django

It has done the above for some time now:

http://pytest-django.readthedocs.org/en/latest/database.html#reuse-db-reuse-the-testing-database-between-test-runs

Guessing that is where Django got the idea.

Chris

--
Adrian Klaver
adrian.klaver@aklaver.com

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general