databases icon indicating copy to clipboard operation
databases copied to clipboard

aiopg reports multiple values for keyword argument "password" when password supplied as kv arg

Open vitodsk opened this issue 5 years ago • 1 comments

Hello, I have the following code: self.database = databases.Database(f'{self.db_engine}://{self.db_user}@{self.db_host}:{self.db_port}/{self.db_database}', password=os.getenv("DB_PASS"), min_size=1, max_size=100)

when I execute that, I get the following error in the trace, I am not sure if something on my side or it is an issue: File "/home/vito/project/venv/lib/python3.8/site-packages/databases/backends/aiopg.py", line 73, in connect self._pool = await aiopg.create_pool( TypeError: create_pool() got multiple values for keyword argument 'password' Given that self.db_engine = 'postgresql+aiopg', seems to me it could be related on how databases module uses the aiopg create_pool() call and translates the parameters. But I can't be sure so I am posting here.

Cheers

vitodsk avatar Oct 26 '20 14:10 vitodsk

This is also a problem for other database drivers like aiomysql. It appears that databases extracts the password out of the URL and then explicitly forwards it to aiopg.create_pool and aiomysql.create_pool but because it calls it like ….create_pool(…, password=self._database_url.password, …, **kwargs), the explicitly provided password in kwargs causes the function call to fail.

Instead, databases should build a dict with its default args (from the URL) and then override those with dict.update(kwargs) to then use the combined dict for the create_pool call.

FichteFoll avatar Aug 20 '24 09:08 FichteFoll