-
-
Notifications
You must be signed in to change notification settings - Fork 1
Update RST documentation for PR#10 multi-database and threading features #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
clauspruefer
merged 4 commits into
main
from
copilot/fix-d6a8fda8-c057-4d41-a9b8-ed1570a890a3
Aug 23, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b9f100a
Initial plan
Copilot 566c375
Update RST documentation files - intro, config, examples, design, bui…
Copilot b5d0c7f
Final documentation improvements - fix table formatting, update CHANG…
Copilot 9363d7a
Fix code block comments to use lowercase formatting
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,19 @@ | ||
| # Changelog | ||
|
|
||
| ## Version 0.98rc1 | ||
| ## Version 1.0rc1 | ||
|
|
||
| - Finish Documentation including Docstrings | ||
| - Fix Metadata | ||
| - **Multi-Database Support**: Added support for multiple database endpoints with automatic load balancing | ||
| - **Threading Models**: Support for both threaded and non-threaded deployment scenarios | ||
| - **Improved Architecture**: Enhanced connection handling and pool management | ||
| - **Documentation**: Complete rewrite of documentation to reflect new features | ||
| - **API Improvements**: Better error handling and connection management | ||
|
|
||
| ## Version 0.99 | ||
|
|
||
| - Add Handler.commit() procedure used for autocommit=False connections | ||
|
|
||
| ## Version 0.98rc1 | ||
|
|
||
| - Finish Documentation including Docstrings | ||
| - Fix Metadata | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,70 @@ | ||
| .. api | ||
| ============================= | ||
| Internal Class Representation | ||
| ============================= | ||
| ============= | ||
| API Reference | ||
| ============= | ||
|
|
||
| pgdbpool | ||
| ======== | ||
| Complete API documentation for pgdbpool classes and functions. | ||
|
|
||
| pgdbpool Module | ||
| =============== | ||
|
|
||
| Core Classes | ||
| ------------ | ||
|
|
||
| .. automodule:: pgdbpool.pool | ||
| :members: Connection, Handler, Query | ||
| :special-members: __init__, __enter__, __exit__ | ||
| :exclude-members: __weakref__ | ||
| :show-inheritance: | ||
|
|
||
| Utility Functions | ||
| ----------------- | ||
|
|
||
| .. automodule:: pgdbpool.pool | ||
| :members: conn_iter | ||
| :exclude-members: __weakref__ | ||
|
|
||
| Exception Classes | ||
| ----------------- | ||
|
|
||
| .. automodule:: pgdbpool.pool | ||
| :members: conn_iter, conn_iter_locked, Connection, Query, Handler | ||
| :special-members: | ||
| :private-members: | ||
| :members: DBConnectionError, DBQueryError, DBOfflineError, UnconfiguredGroupError | ||
| :exclude-members: __weakref__ | ||
| :show-inheritance: | ||
|
|
||
| Class Method Reference | ||
| ====================== | ||
|
|
||
| Connection Class Methods | ||
| ------------------------- | ||
|
|
||
| The Connection class provides static methods for pool management: | ||
|
|
||
| - **init(config)**: Initialize connection pool with configuration | ||
| - **get_threading_model()**: Return current threading model ('threaded' or 'non-threaded') | ||
| - **get_max_pool_size(group)**: Get maximum connections for a group | ||
| - **get_next_connection(group)**: Get next available connection from group | ||
| - **connect(connection)**: Establish database connection | ||
| - **reconnect(connection)**: Reconnect failed database connection | ||
| - **check_db(connection)**: Verify database connection health | ||
|
|
||
| Handler Context Manager | ||
| ----------------------- | ||
|
|
||
| The Handler class provides a context manager for database operations: | ||
|
|
||
| - **__init__(group)**: Initialize handler for connection group | ||
| - **__enter__()**: Enter context, acquire connection | ||
| - **__exit__()**: Exit context, release connection | ||
| - **query(statement, params=None)**: Execute SQL query | ||
| - **query_prepared(params)**: Execute prepared statement | ||
| - **commit()**: Commit transaction (for autocommit=False groups) | ||
|
|
||
| Query Static Methods | ||
| -------------------- | ||
|
|
||
| The Query class provides static methods for SQL execution: | ||
|
|
||
| - **execute(connection, sql_statement, sql_params=None)**: Execute SQL statement | ||
| - **execute_prepared(connection, sql_params)**: Execute prepared statement | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,47 +1,159 @@ | ||
| .. build | ||
| ============ | ||
| Build Module | ||
| ============ | ||
| ================= | ||
| Building pgdbpool | ||
| ================= | ||
|
|
||
| 1. Consider Using Environment | ||
| ============================= | ||
| Guide for building pgdbpool from source code. | ||
|
|
||
| 1. Development Environment Setup | ||
| ================================ | ||
|
|
||
| Python PEP 405 proposes Virtual Environments. Think about using. | ||
| **Virtual Environment (Recommended)** | ||
|
|
||
| 2. Clone Repository | ||
| =================== | ||
| Python PEP 405 virtual environments provide isolated development environments: | ||
|
|
||
| .. code-block:: bash | ||
| # create virtual environment | ||
| python3 -m venv pgdbpool-dev | ||
| source pgdbpool-dev/bin/activate # Linux/macOS | ||
| # pgdbpool-dev\Scripts\activate # Windows | ||
| # upgrade pip | ||
| pip install --upgrade pip | ||
| 2. Source Code Acquisition | ||
| =========================== | ||
|
|
||
| **Clone from GitHub:** | ||
|
|
||
| .. code-block:: bash | ||
| git clone https://github.com/clauspruefer/python-dbpool.git | ||
| cd python-dbpool | ||
| 3. Build As Non Root User | ||
| ========================= | ||
| **Download Release Archive:** | ||
|
|
||
| .. code-block:: bash | ||
| # download latest release | ||
| wget https://github.com/clauspruefer/python-dbpool/archive/refs/tags/v1.0rc1.tar.gz | ||
| tar -xzf v1.0rc1.tar.gz | ||
| cd python-dbpool-1.0rc1 | ||
clauspruefer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 3. Install Dependencies | ||
| ======================= | ||
|
|
||
| **Runtime Dependencies:** | ||
|
|
||
| .. code-block:: bash | ||
| # install postgresql adapter | ||
| pip install psycopg2-binary | ||
| # or compile from source (requires libpq-dev) | ||
| # apt-get install libpq-dev # Debian/Ubuntu | ||
| # pip install psycopg2 | ||
| **Development Dependencies:** | ||
|
|
||
| .. code-block:: bash | ||
| # install testing framework | ||
| pip install pytest pytest-cov | ||
| # install documentation tools (optional) | ||
| pip install sphinx sphinx-rtd-theme | ||
| 4. Build Distribution Package | ||
| ============================= | ||
|
|
||
| **Create Source Distribution:** | ||
|
|
||
| .. code-block:: bash | ||
| python3 setup.py sdist | ||
| # modern way using build | ||
| pip install build | ||
| python -m build --sdist | ||
| 4. Install As Root User | ||
| # legacy way using setuptools | ||
| python setup.py sdist | ||
| **Create Wheel Distribution:** | ||
|
|
||
| .. code-block:: bash | ||
| python -m build --wheel | ||
| 5. Installation Methods | ||
| ======================= | ||
|
|
||
| **Development Installation (Editable):** | ||
|
|
||
| .. code-block:: bash | ||
| sudo pip3 install ./dist/package-0.1.tar.gz | ||
| # install in development mode | ||
| pip install -e . | ||
| or global on restrictive PIP package manager systems ... | ||
| **Local Package Installation:** | ||
|
|
||
| .. code-block:: bash | ||
| sudo pip3 install ./dist/package-0.1.tar.gz --break-system-packages | ||
| # install from built package | ||
| pip install dist/pgdbpool-1.0rc1.tar.gz | ||
| 5. Run Tests | ||
| ============ | ||
| **System-wide Installation:** | ||
|
|
||
| To ensure everything works correctly, run tests (after module installation). | ||
| .. code-block:: bash | ||
| # install system-wide (requires sudo) | ||
| sudo pip install dist/pgdbpool-1.0rc1.tar.gz | ||
| # for restrictive systems | ||
| sudo pip install dist/pgdbpool-1.0rc1.tar.gz --break-system-packages | ||
| 6. Testing | ||
| ========== | ||
|
|
||
| **Run Test Suite:** | ||
|
|
||
| .. code-block:: bash | ||
| # run all tests | ||
| pytest | ||
| # run with coverage report | ||
| pytest --cov=pgdbpool --cov-report=html | ||
| # run specific test file | ||
| pytest test/unit/test_pool.py | ||
| **Test Configuration:** | ||
|
|
||
| Tests require a PostgreSQL database. Set environment variables: | ||
|
|
||
| .. code-block:: bash | ||
| export PSQL_PWD="your_test_db_password" | ||
| export TEST_DB_HOST="localhost" | ||
| export TEST_DB_NAME="test_database" | ||
| export TEST_DB_USER="test_user" | ||
| 7. Documentation Building | ||
| ========================= | ||
|
|
||
| **Build HTML Documentation:** | ||
|
|
||
| .. code-block:: bash | ||
| cd doc/conf.py | ||
| sphinx-build -b html source build/html | ||
| **View Documentation:** | ||
|
|
||
| .. code-block:: bash | ||
| # open in browser | ||
| open build/html/index.html # macOS | ||
| xdg-open build/html/index.html # Linux | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.