3

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

Community
  • 1
  • 1
Acorn
  • 49,061
  • 27
  • 133
  • 172
  • Have you tried connecting to the postgres without specyfing db using psql? As you can see it will always connect to default. So what's wrong with that? – Jakub Kania May 13 '15 at 16:16

1 Answers1

2

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.

Acorn
  • 49,061
  • 27
  • 133
  • 172