Acorn
Acorn

Reputation: 50547

Is it possible to connect to a postgres server with SQLAlchemy without specifying a database?

I'm trying to automatically create a test database before running my tests without shelling out, but I'm struggling to connect to the postgres server without connecting to a database.

If I give create_engine() a URL with .database None it tries to connect to a default database name.

Is what I'm trying to do possible?

I was going a long the lines of this answer: https://stackoverflow.com/a/28784334/311220

Upvotes: 3

Views: 1043

Answers (1)

Acorn
Acorn

Reputation: 50547

One way to achieve this is to connect to the default postgres database which should always be present. Then once connected you can create the desired databases.

Upvotes: 2

Related Questions