tortoise-orm icon indicating copy to clipboard operation
tortoise-orm copied to clipboard

Database creation breaks if user is not `postgres`

Open healroot opened this issue 5 years ago • 0 comments

Describe the bug Tortoise.init(*, _create_db=True) suppose to create database. It does create it if username in config is postgres, but it fails if it is not.

To Reproduce Setup DB with user differenf from postgres. Call Tortoise.init with _create_db=True and config with created user, and not existed database.

Expected behavior New database created.

Actual behavior Its trying to connect to database with name as user name and fails as it does not exist.

Additional context The issue is placed in using asyncpg connections with database=None. The issue source is here - you use asyncpg.create_pull with database=None. Asyncpg in such case take username as value for database name and it works only if username is postgres.

healroot avatar Sep 06 '21 13:09 healroot