Name | django-gbasedbtdb JSON |
Version |
1.11.5
JSON |
| download |
home_page | None |
Summary | A database driver for Django to connect to an GBase 8s db via ODBC |
upload_time | 2024-08-22 02:27:24 |
maintainer | None |
docs_url | None |
author | None |
requires_python | None |
license | APLv2 |
keywords |
django
gbasedbt
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
Django GBasedbtDB
==================
A database driver for Django to connect to an GBase 8s database via pyodbc.
**Some limitations**:
- Does not support default values
- GBase 8s automatically creates indexes on foreign keys, but Django attempts to do that
manually; the current implementation here just attempts to catch the error on index
creation. It may unintentionally catch other index creation errors where the index
already exists.
Configure local environment
---------------------------
The following environment variables should exist:
GBASEDBTDIR
The path to the GBase 8s client install directory
GBASEDBTSERVER
The name of the GBase 8s service to which we need to connect
GBASEDBTSQLHOSTS
The path to the ``sqlhosts`` file that the GBase 8s driver should use
LD_LIBRARY_PATH
The path(s) to the various GBase 8s library files: Usually
``$GBASEDBTDIR/lib:$GBASEDBTDIR/lib/cli:$GBASEDBTDIR/lib/esql``
DB_LOCALE
In case of ``Database locale information mismatch.`` error during connection,
you should specify your database locale, e.g. ``DB_LOCALE=en_US.8859-15``
You will also need to add an entry within your ``sqlhosts`` file for each remote/local GBase 8s
server connection in the following format::
<GBASEDBT_SERVER_NAME> onsoctcp <GBASEDBT_HOST_NAME> <GBASEDBT_SERVICE_NAME>
For example::
dev onsoctcp localhost 9088
You may alternatively use a symbolic name in that line in place of the port number, typically ``sqlexec`` and
then configure the port number in the ``/etc/services`` file::
sqlexec 9088/tcp
Configure settings.py
---------------------
Django’s settings.py uses the following to connect to an GBase 8s database:
.. code-block:: python
'default': {
'ENGINE': 'django_gbasedbtdb',
'NAME': 'myproject',
'SERVER': 'ifxserver',
'USER' : 'testuser',
'PASSWORD': 'passw0rd',
'OPTIONS': {
'DRIVER': '/path/to/iclit09b.so'. # Or iclit09b.dylib on macOS
'CPTIMEOUT': 120,
'CONN_TIMEOUT': 120,
'ISOLATION_LEVEL': 'READ_UNCOMMITTED',
'LOCK_MODE_WAIT': 0,
'VALIDATE_CONNECTION': True,
},
'CONNECTION_RETRY': {
'MAX_ATTEMPTS': 10,
},
'TEST': {
'NAME': 'myproject',
'CREATE_DB': False
}
}
CPTIMEOUT
This will set connection pooling timeout.
Possible values::
0 - Turn off connection pooling
nn - timeout set nn seconds
CONN_TIMEOUT
This will set timeout for operations on connections (connection, ??closing??, we're not sure).
Possible values::
0 - Default timeout to the database (which could mean no timeout)
nn - timeout set nn seconds
ISOLATION_LEVEL
This will set database isolation level at connection level
Possible values::
READ_COMMITED
READ_UNCOMMITTED
SERIALIZABLE
LOCK_MODE_WAIT
This will set database LOCK MODE WAIT at connection level
Application can use this property to override the default server
process for accessing a locked row or table.
The default value is 0 (do not wait for the lock).
Possible values::
-1 - WAIT until the lock is released.
0 - DO NOT WAIT, end the operation, and return with error.
nn - WAIT for nn seconds for the lock to be released.
VALIDATE_CONNECTION
Whether existing connections should be validated at the start of the request. Defaults to
`False`.
VALIDATION_INTERVAL
How often in seconds to revalidate connections if `VALIDATE_CONNECTION` is enabled. Defaults to
`300` (5 minutes).
VALIDATION_QUERY
Query used to validate whether a connection is usable. Defaults to
`"SELECT 1 FROM sysmaster:sysdual"`.
CONNECTION_RETRY
When opening a new connection to the database, automatically retry up to ``MAX_ATTEMPTS`` times
in the case of errors. Only error codes in ``ERRORS`` will trigger a retry. The wait time
between retries is calculated using an exponential backoff with jitter formula::
random_between(WAIT_MIN, min(WAIT_MAX, WAIT_MULTIPLIER * WAIT_EXP_BASE ** (attempt - 1)))
Defaults (wait times are in milliseconds)::
MAX_ATTEMPTS: 1 # this implies no retries
WAIT_MIN: 0
WAIT_MAX: 1000
WAIT_MULTIPLIER: 25
WAIT_EXP_BASE: 2
ERRORS: ['-908', '-930', '-27001']
Each of these settings can be overridden in the ``CONNECTION_RETRY`` section of the database
configuration in ``settings.py``. For example::
DATABASES = {
'default': {
'ENGINE': 'django_gbasedbtdb',
'CONNECTION_RETRY': {
'MAX_ATTEMPTS': 10,
'WAIT_MIN': 0,
'WAIT_MAX': 500,
},
# ...
},
}
The error codes that are retried by default correspond to the following errors:
* ``-908 Attempt to connect to database server (servername) failed``
* ``-930 Cannot connect to database server servername``
* ``-27001 Read error occurred during connection attempt``
These errors are often seen when the database server is too busy, too many clients are
attempting to connect at the same time or a network firewall has chopped the connection.
.. note:
The ``DRIVER`` option is optional, default locations will be used per platform if it is not provided.
.. note:
The ``TEST`` option sets test parametes. Use ``NAME`` to override the name of the test database
and set ``CREATE_DB`` to ``False`` to prevent Django from attempting to create a new test
database.
Testing against an GBase 8s Database
------------------------------------
Due to a bug in the GBase 8s ODBC driver, it is not currently possible to run Django tests normally. Specifically, it is not possible for Django to create a test database. As such, you will need to do it manually. By default Django will attempt to create a database with a name equal to the default database name with a ``test_`` prefix. e.g. if you database name is ``my_database``, the test database name would be ``test_my_database``. This can be overridden with the ``NAME`` option under ``TEST``.
To prevent Django from attempting to create a test database, set the ``CREATE_DB`` option
under ``TEST`` to ``False``: see 'Configure settings.py' above.
You can follow the steps above, in the section on using GBase 8s locally with Docker to create a test database. Then when running the test you can tell Django to re-use an existing database, rather than trying to create a new one with the ``-k`` parameter:
.. code-block:: bash
./manage.py test -k
For django_gbasedbtdb Developers
--------------------------------
To run the django_gbasedbtdb test suite, you need to set the GBASEDBTDIR environment variable, and the tests
expect an GBase 8s database at host "gbasedbt". Change that host in `test/conftest.py` if you need to.
Then run the test suite with:
tox
This will run the tests under Django 3 and 4.
Release History
---------------
Version 1.11.5
- Fork from django_informixdb
- Fix 'unsupported column type -114'
Raw data
{
"_id": null,
"home_page": null,
"name": "django-gbasedbtdb",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "django, gbasedbt",
"author": null,
"author_email": "liaosnet <liaosnet@gbasedbt.com>",
"download_url": "https://files.pythonhosted.org/packages/a8/d9/f11c79ce2d05c31932d5eaf6745530ccd510bd644fe80d010e5af77bc574/django_gbasedbtdb-1.11.5.tar.gz",
"platform": null,
"description": "Django GBasedbtDB\n==================\n\nA database driver for Django to connect to an GBase 8s database via pyodbc.\n\n**Some limitations**:\n\n- Does not support default values\n- GBase 8s automatically creates indexes on foreign keys, but Django attempts to do that\n manually; the current implementation here just attempts to catch the error on index\n creation. It may unintentionally catch other index creation errors where the index\n already exists.\n\n\nConfigure local environment\n---------------------------\n\nThe following environment variables should exist:\n\nGBASEDBTDIR\n The path to the GBase 8s client install directory\n\nGBASEDBTSERVER\n The name of the GBase 8s service to which we need to connect\n\nGBASEDBTSQLHOSTS\n The path to the ``sqlhosts`` file that the GBase 8s driver should use\n\nLD_LIBRARY_PATH\n The path(s) to the various GBase 8s library files: Usually\n ``$GBASEDBTDIR/lib:$GBASEDBTDIR/lib/cli:$GBASEDBTDIR/lib/esql``\n\nDB_LOCALE\n In case of ``Database locale information mismatch.`` error during connection,\n you should specify your database locale, e.g. ``DB_LOCALE=en_US.8859-15``\n\nYou will also need to add an entry within your ``sqlhosts`` file for each remote/local GBase 8s\nserver connection in the following format::\n\n <GBASEDBT_SERVER_NAME> onsoctcp <GBASEDBT_HOST_NAME> <GBASEDBT_SERVICE_NAME>\n\nFor example::\n\n dev onsoctcp localhost 9088\n\nYou may alternatively use a symbolic name in that line in place of the port number, typically ``sqlexec`` and\nthen configure the port number in the ``/etc/services`` file::\n\n sqlexec 9088/tcp\n\n\nConfigure settings.py\n---------------------\n\nDjango\u2019s settings.py uses the following to connect to an GBase 8s database:\n\n.. code-block:: python\n\n 'default': {\n 'ENGINE': 'django_gbasedbtdb',\n 'NAME': 'myproject',\n 'SERVER': 'ifxserver',\n 'USER' : 'testuser',\n 'PASSWORD': 'passw0rd',\n 'OPTIONS': {\n 'DRIVER': '/path/to/iclit09b.so'. # Or iclit09b.dylib on macOS\n 'CPTIMEOUT': 120,\n 'CONN_TIMEOUT': 120,\n 'ISOLATION_LEVEL': 'READ_UNCOMMITTED',\n 'LOCK_MODE_WAIT': 0,\n 'VALIDATE_CONNECTION': True,\n },\n 'CONNECTION_RETRY': {\n 'MAX_ATTEMPTS': 10,\n },\n 'TEST': {\n 'NAME': 'myproject',\n 'CREATE_DB': False\n }\n }\n\nCPTIMEOUT\n This will set connection pooling timeout.\n Possible values::\n\n 0 - Turn off connection pooling\n nn - timeout set nn seconds\n\nCONN_TIMEOUT\n This will set timeout for operations on connections (connection, ??closing??, we're not sure).\n Possible values::\n\n 0 - Default timeout to the database (which could mean no timeout)\n nn - timeout set nn seconds\n\nISOLATION_LEVEL\n This will set database isolation level at connection level\n Possible values::\n\n READ_COMMITED\n READ_UNCOMMITTED\n SERIALIZABLE\n\nLOCK_MODE_WAIT\n This will set database LOCK MODE WAIT at connection level\n Application can use this property to override the default server\n process for accessing a locked row or table.\n The default value is 0 (do not wait for the lock).\n Possible values::\n\n -1 - WAIT until the lock is released.\n 0 - DO NOT WAIT, end the operation, and return with error.\n nn - WAIT for nn seconds for the lock to be released.\n\nVALIDATE_CONNECTION\n Whether existing connections should be validated at the start of the request. Defaults to\n `False`.\n\nVALIDATION_INTERVAL\n How often in seconds to revalidate connections if `VALIDATE_CONNECTION` is enabled. Defaults to\n `300` (5 minutes).\n\nVALIDATION_QUERY\n Query used to validate whether a connection is usable. Defaults to\n `\"SELECT 1 FROM sysmaster:sysdual\"`.\n\nCONNECTION_RETRY\n When opening a new connection to the database, automatically retry up to ``MAX_ATTEMPTS`` times\n in the case of errors. Only error codes in ``ERRORS`` will trigger a retry. The wait time\n between retries is calculated using an exponential backoff with jitter formula::\n\n random_between(WAIT_MIN, min(WAIT_MAX, WAIT_MULTIPLIER * WAIT_EXP_BASE ** (attempt - 1)))\n\n Defaults (wait times are in milliseconds)::\n\n MAX_ATTEMPTS: 1 # this implies no retries\n WAIT_MIN: 0\n WAIT_MAX: 1000\n WAIT_MULTIPLIER: 25\n WAIT_EXP_BASE: 2\n ERRORS: ['-908', '-930', '-27001']\n\n Each of these settings can be overridden in the ``CONNECTION_RETRY`` section of the database\n configuration in ``settings.py``. For example::\n\n DATABASES = {\n 'default': {\n 'ENGINE': 'django_gbasedbtdb',\n 'CONNECTION_RETRY': {\n 'MAX_ATTEMPTS': 10,\n 'WAIT_MIN': 0,\n 'WAIT_MAX': 500,\n },\n # ...\n },\n }\n\n The error codes that are retried by default correspond to the following errors:\n\n * ``-908 Attempt to connect to database server (servername) failed``\n * ``-930 Cannot connect to database server servername``\n * ``-27001 Read error occurred during connection attempt``\n\n These errors are often seen when the database server is too busy, too many clients are\n attempting to connect at the same time or a network firewall has chopped the connection.\n\n\n.. note:\n The ``DRIVER`` option is optional, default locations will be used per platform if it is not provided.\n\n.. note:\n The ``TEST`` option sets test parametes. Use ``NAME`` to override the name of the test database\n and set ``CREATE_DB`` to ``False`` to prevent Django from attempting to create a new test\n database.\n\n\nTesting against an GBase 8s Database\n------------------------------------\n\nDue to a bug in the GBase 8s ODBC driver, it is not currently possible to run Django tests normally. Specifically, it is not possible for Django to create a test database. As such, you will need to do it manually. By default Django will attempt to create a database with a name equal to the default database name with a ``test_`` prefix. e.g. if you database name is ``my_database``, the test database name would be ``test_my_database``. This can be overridden with the ``NAME`` option under ``TEST``.\n\nTo prevent Django from attempting to create a test database, set the ``CREATE_DB`` option\nunder ``TEST`` to ``False``: see 'Configure settings.py' above.\n\nYou can follow the steps above, in the section on using GBase 8s locally with Docker to create a test database. Then when running the test you can tell Django to re-use an existing database, rather than trying to create a new one with the ``-k`` parameter:\n\n.. code-block:: bash\n\n ./manage.py test -k\n\n\nFor django_gbasedbtdb Developers\n--------------------------------\n\nTo run the django_gbasedbtdb test suite, you need to set the GBASEDBTDIR environment variable, and the tests\nexpect an GBase 8s database at host \"gbasedbt\". Change that host in `test/conftest.py` if you need to.\nThen run the test suite with:\n\n tox\n\nThis will run the tests under Django 3 and 4.\n\n\nRelease History\n---------------\n\nVersion 1.11.5\n\n- Fork from django_informixdb\n- Fix 'unsupported column type -114'\n\n",
"bugtrack_url": null,
"license": "APLv2",
"summary": "A database driver for Django to connect to an GBase 8s db via ODBC",
"version": "1.11.5",
"project_urls": {
"Homepage": "https://github.com/liaosnet/django_gbasedbtdb",
"Repository": "https://github.com/liaosnet/django_gbasedbtdb"
},
"split_keywords": [
"django",
" gbasedbt"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "a35101d459f3ac53f98e81eece029c24709bf211ee81f63af35d09ae5141f1d3",
"md5": "9c03649807587ce87072d2dd2d91bb89",
"sha256": "6c03f994d1c2d007bede8bd2c38573e7f2458aee9128f3057c65e08ac7acb2a5"
},
"downloads": -1,
"filename": "django_gbasedbtdb-1.11.5-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "9c03649807587ce87072d2dd2d91bb89",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": null,
"size": 26542,
"upload_time": "2024-08-22T02:27:22",
"upload_time_iso_8601": "2024-08-22T02:27:22.410613Z",
"url": "https://files.pythonhosted.org/packages/a3/51/01d459f3ac53f98e81eece029c24709bf211ee81f63af35d09ae5141f1d3/django_gbasedbtdb-1.11.5-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "a8d9f11c79ce2d05c31932d5eaf6745530ccd510bd644fe80d010e5af77bc574",
"md5": "68d244e63d279110a0600901a73277c7",
"sha256": "5a8c9206ddc708fc3221b175bea4cf633260b1506b99d3f6f78cdb5cda5384f0"
},
"downloads": -1,
"filename": "django_gbasedbtdb-1.11.5.tar.gz",
"has_sig": false,
"md5_digest": "68d244e63d279110a0600901a73277c7",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 28054,
"upload_time": "2024-08-22T02:27:24",
"upload_time_iso_8601": "2024-08-22T02:27:24.623349Z",
"url": "https://files.pythonhosted.org/packages/a8/d9/f11c79ce2d05c31932d5eaf6745530ccd510bd644fe80d010e5af77bc574/django_gbasedbtdb-1.11.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-22 02:27:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "liaosnet",
"github_project": "django_gbasedbtdb",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "django-gbasedbtdb"
}