testcontainers / testcontainers/testcontainers-python
Creating a Postgres contrainer with an async driver fails
Nobody has claimed this yet.
- #320 by @fourteekey — closed without merging
- Dominant language
- Python
- Stars
- 2.3k
- Forks
- 386
- Avg merge
- 4h 40m
- Merged PRs (30d)
- 1
Description
Hello,
When creating a new database container, testcontainers automatically tries to connect to it here, but if I specify an async driver (e.g. PostgresContainer("postgres:14.4", driver="asyncpg")) sqlalchemy tries to use that and fails because it's not in an async context.
Is there any way to skip trying to connect to the database or fix it so it can also handle async context?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at testcontainers/core/generic.py around line 55 and trace how PostgresContainer("postgres:14.4", driver="asyncpg") builds and connects through SQLAlchemy. Check the existing handling of driver selection and the closed linked pull request for context. Done means creating a container with an async driver no longer fails during automatic connection, with the intended skip or async-context behavior covered by a test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python, sqlalchemy
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100