GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat(generic): Reintroducing the generic SQL module by Tranquility2 · Pull Request #892 · testcontainers/testcontainers-python

Conversation

@Tranquility2

@Tranquility2 Tranquility2 commented Oct 2, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Related to #884
Trying to replace the old generic.py in core to a nicer version under the generic module.

SqlContainer its not as good (in being generic) as ServerContainer but it should allow us to deprecate core/testcontainers/core/generic.py with minimal effort for users, it could lead to a more Generic version like DBContainer in the future.

Update 1: Refactor to use SqlConnectWaitStrategy
Update 2: Now SqlConnectWaitStrategy is required and the users can provide SqlContainer with any wait strategy.
Update 3: Now utilizes all the latest improvements from WaitStrategy

Note: I think the added tests + documentation (provided in this PR) are by themselves a great improvement over the current generic.py

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

rhoban13 reacted with heart emoji surister reacted with eyes emoji
All reactions
  • ❤️ 1 reaction
  • 👀 1 reaction
@Tranquility2 Tranquility2 mentioned this pull request Oct 2, 2025
What class to use to implement or migrate database modules #884
Closed
@codecov

codecov Bot commented Oct 3, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.86%. Comparing base (af382f7) to head (d502fb6).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #892   +/-   ##
=======================================
  Coverage   78.86%   78.86%           
=======================================
  Files          14       14           
  Lines        1221     1221           
  Branches      142      142           
=======================================
  Hits          963      963           
  Misses        216      216           
  Partials       42       42           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Tranquility2 Tranquility2 linked an issue Oct 3, 2025 that may be closed by this pull request
What class to use to implement or migrate database modules #884
Closed
@Tranquility2 Tranquility2 changed the title feat(generic): Added generic SQL module feat(generic): Reintroducing the generic SQL module Oct 3, 2025
@Tranquility2
Tranquility2 requested a review from alexanderankin October 3, 2025 10:53
surister
surister reviewed Oct 3, 2025
View reviewed changes
Comment thread modules/generic/testcontainers/generic/sql.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@alexanderankin

alexanderankin commented Oct 3, 2025

Copy link
Copy Markdown
Member

can we add a new extra? like a db (or more accurately, sql) extra? this is assuming we dont want to aim for complete removal.

Even if we do that, i dont like the _connect method on the container - i think connecting is the business of 1) app code 2) sql waiting strategy - so all the db interface has to do is tell someone how to connect - and maybe this can just return the url?

This second point is made further complicated by now you can only use this waiting strategy on container that have the interface implemented. i think maybe this waiting strategy can be parametrized - with information on how to build the url. this removes the need for the container to build its own url (finally). just a thought.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Tranquility2

Tranquility2 commented Oct 3, 2025

Copy link
Copy Markdown
Contributor Author
  • The new extra sound a bit like an overkill and could be a bit confusing for the users don't you think? My goal was to make the transition as seamless as possible but I agree it might be a good time to rethink some things. I just don't want to "branch out" too much, all in all its a very good point but I concerned it will be lost will all the other sql modules 😓
  • I totally understand your point regarding _connect , I had one iteration where all the logic was under ConnectWaitStrategy (with no _connect at all) and I assumed we want backward compatibility with DbContainer so it will be easier to move to (so we can remove generic.py), let me try and do another version without the connect and ConnectWaitStrategy more parametrized as you suggested.
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Tranquility2

Tranquility2 commented Oct 3, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

New version is ready:

  1. no more _connect
  2. all extended logic moved to SqlConnectWaitStrategy (new file) making sql.py much cleaner and more generic
  3. smaller improvements to make the code simpler and easier to maintain

You can now say SqlConnectWaitStrategy is basically sqlalchemyConnectWaitStrategy 😂 but this can also be improved and made more generic.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@surister

surister commented Oct 3, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

I like the new SqlConnectWaitStrategy a lot. Indirectly the _connect method paired with wait_container_is_ready did just that in many database modules.

Tranquility2 reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Tranquility2

Tranquility2 commented Oct 4, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

Make one more critical improvement, now wait_strategy is a param for the SqlContainer, this

  1. keeps it very generic - all the others can use it with ease
  2. provides SqlConnectWaitStrategy if anyone needs its
  3. allows each module to provide a custom wait_strategy (that can be as simple as waiting for some log string from the server)
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Tranquility2

Tranquility2 commented Oct 4, 2025 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@alexanderankin now using WaitStrategy._poll and with_transient_exceptions from your latest improvements.
This makes SqlConnectWaitStrategy much simpler cleaner, thanks 🙏

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Tranquility2
Tranquility2 requested a review from surister October 4, 2025 10:22
@Tranquility2
Tranquility2 force-pushed the generic_sql branch from 91d8161 to a99045a Compare October 4, 2025 10:23
@surister surister mentioned this pull request Oct 5, 2025
fix(modules): Fix postgres deprecation warning. #883
Closed
surister
surister approved these changes Oct 5, 2025
View reviewed changes

@surister surister left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried to migrate Postgres and CrateDB module and it's fairly easy, I left a few nitpicks that you might use as inspiration, otherwise LGTM and I'd merge.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Tranquility2 reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread modules/generic/testcontainers/generic/sql.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread modules/generic/testcontainers/generic/sql.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@Tranquility2
Tranquility2 force-pushed the generic_sql branch 2 times, most recently from a05abdb to bf6a553 Compare October 5, 2025 14:51
rhoban13
rhoban13 reviewed Oct 8, 2025
View reviewed changes

@rhoban13 rhoban13 left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall clearly an improvement on the existing DbContainer. A few questions/ideas inline, many to clarify my own understanding of stuff.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Tranquility2 reacted with eyes emoji
All reactions
  • 👀 1 reaction
Comment thread core/testcontainers/core/generic.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread modules/generic/testcontainers/generic/providers/sql_connection_wait_strategy.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread modules/generic/testcontainers/generic/providers/sql_connection_wait_strategy.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread modules/generic/testcontainers/generic/sql.py
Raises:
NotImplementedError: Must be implemented by subclasses
"""
raise NotImplementedError("Subclasses must implement get_connection_url()")

@rhoban13 rhoban13 Oct 8, 2025

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this have a default implementation to just call _create_connection_url? The SimpleSqlContainer implements it in this way & this feels like a reasonable default. I suspect most users of this class would either duplicate the implementation, or call the private method anyway which I think we'd want to discourage.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@Tranquility2 Tranquility2 Oct 8, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SimpleSqlContainer is just a test, are you sure this is the default for all SQL related implementations?
for example Postgres needs driver so its not the exact same, but an extended build using the baseline _create_connection_url which is great. I personally like the current design and believe/hope it allows for max flexibility in the future.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread modules/generic/testcontainers/generic/sql.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread modules/generic/testcontainers/generic/sql.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread modules/generic/testcontainers/generic/providers/sql_connection_wait_strategy.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

@surister surister mentioned this pull request Oct 16, 2025
feat(cratedb): Add Cratedb module #888
Open
Tranquility2 added 10 commits March 28, 2026 19:52
@Tranquility2
Remove comment line
470baf7
@Tranquility2
Added base generic db
41f3758
@Tranquility2
Rename test_generic
8ee2f1a
@Tranquility2
Renamed DB to SQL
190dbfb
@Tranquility2
Tests for SQL
6326c47
@Tranquility2
Update warnning
989f677
@Tranquility2
update docs
42f4aea
@Tranquility2
Fix doctests
791d6af
@Tranquility2
Add generic dep
21461e3
@Tranquility2
Update ref
7321fc2
Tranquility2 added 16 commits March 28, 2026 19:59
@Tranquility2
Replaced wait
619940d
@Tranquility2
Improve Strategy
60dcf01
@Tranquility2
Better Strategy
abd05d0
@Tranquility2
Remove _connect
56628aa
@Tranquility2
Refactor generic sql
51591ae
@Tranquility2
SQL container with configurable wait strategy
cdbdabb
@Tranquility2
use WaitStrategy._poll and with_transient_exceptions
ef4d571
@Tranquility2
Required wait_strategy
44a0343
@Tranquility2
Added note
de608a2
@Tranquility2
Move connector and Rename
0f0eb9e
@Tranquility2
Update doctests
f9bf8e2
@Tranquility2
Fix doctest
988a6ca
@Tranquility2
Remove extra validation + Improve testing
7fa1105
@Tranquility2
Omit generic.py from report
f613a61
@Tranquility2
Renamed sql_connector
07c8781
@Tranquility2
Renamed SqlConnectWaitStrategy
d59870a
@Tranquility2
Tranquility2 force-pushed the generic_sql branch from aacc13a to d59870a Compare March 28, 2026 20:07
@Tranquility2
Revert "Omit generic.py from report"
d502fb6
This reverts commit f613a61.
alexanderankin
alexanderankin approved these changes Mar 29, 2026
View reviewed changes
@alexanderankin
alexanderankin merged commit 2ca2321 into testcontainers:main Mar 29, 2026
12 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Mar 24, 2026
chore(main): release testcontainers 4.15.0-rc.1 #986
Merged
alexanderankin added a commit that referenced this pull request Apr 7, 2026
@github-actions @alexanderankin
chore(main): release testcontainers 4.15.0-rc.1 (#986)
6ecf347
🤖 I have created a release *beep* *boop*
---


##
[4.15.0-rc.1](testcontainers-v4.14.2...testcontainers-v4.15.0-rc.1)
(2026-04-07)


### Features

* **compose:** add structured container inspect information
([#897](#897))
([58459a1](58459a1))
* **core:** support SSH-based DOCKER_HOST
([#993](#993))
([d48115d](d48115d))
* **generic:** Reintroducing the generic SQL module
([#892](#892))
([2ca2321](2ca2321))
* **keycloak:** support for relative path and management relative path
([#982](#982))
([898faf6](898faf6))
* **mqtt:** MosquittoContainer: Add version 2.1.2
([#978](#978))
([af382f7](af382f7))


### Bug Fixes

* **azurite:** make visible to type checkers
([#927](#927))
([baa5668](baa5668))
* **clickhouse:** add `HttpWaitStrategy` instead of deprecated
`wait_container_is_ready`
([#962](#962))
([8034541](8034541))
* **compose:** return type in get_service_port docstring
([#939](#939))
([fed65fe](fed65fe))
* **core:** Refactor copy file
([#996](#996))
([0e0bb24](0e0bb24))
* **core:** wait for ryuk more reliably, improve tests: long_running,
filter logs
([#984](#984))
([b12ae13](b12ae13))
* **generic:** Migrate ServerContainer from deprecated decorator to
HttpWaitStrategy
([#971](#971))
([460b0d8](460b0d8))
* **kafka:** Use wait strategy instead of deprecated wait_for_logs
([#903](#903))
([87332c1](87332c1))
* **postgres:** add py.typed marker to postgres module
([#849](#849))
([c8a5bbd](c8a5bbd))
* **qdrant:** migrate Qdrant from deprecated decorator.
([#963](#963))
([407f798](407f798))
* **redis:** Use wait strategy instead of deprecated decorator
([#914](#914))
([e25713a](e25713a))
* **sftp:** Avoid using wait_for_logs in module.
([#995](#995))
([83157eb](83157eb))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: David Ankin <[email protected]>
florinutz added a commit to florinutz/testcontainers-python that referenced this pull request Jun 11, 2026
@florinutz @surister
fix(cratedb): add CrateDB community module
e3f851c
Add a CrateDB module under testcontainers.community.cratedb, ported from
testcontainers#888 onto the current src/ layout and refactored onto the generic
DbContainer base (per testcontainers#892), following the PostgresContainer pattern.

- CrateDBContainer extends core.generic.DbContainer; single-node command,
  HTTP (4200) wait strategy, crate:// SQLAlchemy connection URL
- deprecation shim at testcontainers.cratedb
- tests under tests/community/cratedb, docs, and the `cratedb` optional-dependency
- sqlalchemy-cratedb added to the test dependency group

Supersedes testcontainers#888.

Co-authored-by: surister <[email protected]>
florinutz added a commit to florinutz/testcontainers-python that referenced this pull request Jun 11, 2026
@florinutz @surister @claude
fix(cratedb): add CrateDB community module
2fc186e
Add a CrateDB module under testcontainers.community.cratedb, ported from
testcontainers#888 and built on the generic SqlContainer base reintroduced in testcontainers#892.

- CrateDBContainer extends community.generic.sql.SqlContainer; single-node
  command, HTTP (4200) wait strategy so startup needs no DB client library,
  crate:// SQLAlchemy connection URL
- deprecation shim at testcontainers.cratedb
- tests under tests/community/cratedb, docs, mkdocs nav entry, and the
  `cratedb` optional-dependency (empty; sqlalchemy-cratedb is a test-group dep)

Supersedes testcontainers#888.

Co-authored-by: surister <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
florinutz added a commit to florinutz/testcontainers-python that referenced this pull request Jun 11, 2026
@florinutz @surister
fix(cratedb): add CrateDB community module
bd181e9
Add a CrateDB module under testcontainers.community.cratedb, ported from
testcontainers#888 and built on the generic SqlContainer base reintroduced in testcontainers#892.

- CrateDBContainer extends community.generic.sql.SqlContainer; single-node
  command, HTTP (4200) wait strategy so startup needs no DB client library,
  crate:// SQLAlchemy connection URL
- deprecation shim at testcontainers.cratedb
- tests under tests/community/cratedb, docs, mkdocs nav entry, and the
  `cratedb` optional-dependency (empty; sqlalchemy-cratedb is a test-group dep)

Supersedes testcontainers#888.

Co-authored-by: surister <[email protected]>
This was referenced Jun 11, 2026
fix(cratedb): add CrateDB community module #1051
Merged
Testing: Testcontainers for Python crate/cratedb-examples#72
Closed
florinutz added a commit to florinutz/testcontainers-python that referenced this pull request Jun 15, 2026
@florinutz @surister
fix(cratedb): add CrateDB community module
0dd50a0
Add a CrateDB module under testcontainers.community.cratedb, ported from
testcontainers#888 and built on the generic SqlContainer base reintroduced in testcontainers#892.

- CrateDBContainer extends community.generic.sql.SqlContainer; single-node
  command, HTTP (4200) wait strategy so startup needs no DB client library,
  crate:// SQLAlchemy connection URL
- deprecation shim at testcontainers.cratedb
- tests under tests/community/cratedb, docs, mkdocs nav entry, and the
  `cratedb` optional-dependency (empty; sqlalchemy-cratedb is a test-group dep)

Supersedes testcontainers#888.

Co-authored-by: surister <[email protected]>
alexanderankin pushed a commit that referenced this pull request Jun 15, 2026
@florinutz @surister @amotl
fix(cratedb): add CrateDB community module (#1051)
0976c7e
Add a CrateDB module under testcontainers.community.cratedb, ported from
#888 and built on the generic SqlContainer base reintroduced in #892.

- CrateDBContainer extends community.generic.sql.SqlContainer;
single-node command, HTTP (4200) wait strategy so startup needs no DB
client library, crate:// SQLAlchemy connection URL
- deprecation shim at testcontainers.cratedb
- tests under tests/community/cratedb, docs, mkdocs nav entry, and the
`cratedb` optional-dependency (empty; sqlalchemy-cratedb is a test-group
dep)

Supersedes #888

---------

Co-authored-by: surister <[email protected]>
Co-authored-by: Andreas Motl <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@alexanderankin alexanderankin alexanderankin approved these changes
+2 more reviewers
@surister surister surister approved these changes
@rhoban13 rhoban13 rhoban13 left review comments
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

What class to use to implement or migrate database modules

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@Tranquility2 @alexanderankin @surister @rhoban13
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.