You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Design question / is a hard dependency on SqlAlchemy really necessary? #336
It seems that the _connect method is causing the DbContainer project to take a hard dependency on SqlAlchemy. This is troublesome for those of us not using that package. Is it meant to do more than verify the database container is up & running? If not, maybe there's a more neutral way of checking like using pg_isready?
changed the title [-]Design question / is a hard dependency on SqlAlchemy reall necessary?[/-][+]Design question / is a hard dependency on SqlAlchemy really necessary?[/+]on Apr 18, 2023
Yes, that's a good point. We should move away from a hard dependency on sqlalchemy as you suggested. Do you have thoughts on how to integrate that change? A PR would be very welcome!
i thought to use popen to execute the pg_isready command, does that sound like a reasonable approach?
Based on my experience maintaining TC for .NET, waiting for pg_isready to succeed is not always reliable. There were instances where the .NET Npgsql client could not establish a connection. Since I wait for specific log messages, I have not encountered any connection issues.
You can see 2 possible implementations, one based on pg_isready the other checking logs as described by @HofmeisterAn. Using pg_isready is much less code and seems to work, but I'm happy to go with either.
Also, would you all require a change to the way all databases are verified, or would you accept a change only for Postgres?
Activity
[-]Design question / is a hard dependency on SqlAlchemy reall necessary?[/-][+]Design question / is a hard dependency on SqlAlchemy really necessary?[/+]tillahoffmann commentedon Apr 22, 2023
Yes, that's a good point. We should move away from a hard dependency on sqlalchemy as you suggested. Do you have thoughts on how to integrate that change? A PR would be very welcome!
logicbomb commentedon Apr 22, 2023
i thought to use
popento execute thepg_isreadycommand, does that sound like a reasonable approach?HofmeisterAn commentedon Apr 22, 2023
Based on my experience maintaining TC for .NET, waiting for
pg_isreadyto succeed is not always reliable. There were instances where the .NET Npgsql client could not establish a connection. Since I wait for specific log messages, I have not encountered any connection issues.logicbomb commentedon Apr 22, 2023
I put together a WIP here: https://github.com/logicbomb/testcontainers-python/pull/1/files
You can see 2 possible implementations, one based on
pg_isreadythe other checking logs as described by @HofmeisterAn. Usingpg_isreadyis much less code and seems to work, but I'm happy to go with either.Also, would you all require a change to the way all databases are verified, or would you accept a change only for Postgres?
tillahoffmann commentedon Apr 23, 2023
You may want to have a look at the
wait_for_logsfunction here. That should reduce the amount of code required.logicbomb commentedon Apr 23, 2023
ooh,
wait_for_logsis nice. i take it you prefer that approach?1 remaining item
logicbomb commentedon Apr 23, 2023
#340
feat(postgres): Remove SqlAlchemy dependency from postgres container (t…
fix(postgres): Remove SqlAlchemy dependency from postgres container (#…
feat(postgres): Remove SqlAlchemy dependency from postgres container (t…