Skip to main content

SQLAlchemy support for Db2 on IBM i

Project description

SQLAlchemy adapter for IBM i

Latest version released on PyPi Supported Python Version Badge Documentation Status

The IBM i SQLAlchemy adapter provides an SQLAlchemy interface to Db2 for IBM i.

Please note that this project is still under active development. Please report any bugs in the issue tracker :rotating_light:

Requirements

SQLAlchemy

SQLAlchemy Version Supported Notes
SQLAlchemy 1.3 Most tested.
SQLAlchemy 1.4 Preliminary support added in 0.9.3.
SQLAlchemy 2.0+ Currently not supported, but planned for 0.9.4.

Python

Python 3.7 - 3.11 are supported. Support for Python 3.12 and up is currently broken.

IBM i Access ODBC Driver

It is best to use the latest version of the driver, which is currently available in the IBM i Access Client Solutions Application Package 1.1.0.27.

Some options may require certain minimum driver versions to be enabled. Because the driver ignores any unknown options, using them on older driver versions will not cause an error but instead be silently ignored.

Connection Option Required Version
trim_char_fields 1.1.0.25

IBM i

This adapter is only tested against IBM i 7.3 and up. It may support older IBM i releases, but no support is guaranteed.

Installation

pip install sqlalchemy-ibmi

Getting Started

You will need to have the IBM i Access ODBC Driver installed in order to use this adapter. Please read these docs for the simplest way to install for your platform.

import sqlalchemy as sa
engine = sa.create_engine("ibmi://user:password@host.example.com")

cnxn = engine.connect()
metadata = sa.MetaData()
table = sa.Table('table_name', metadata, autoload=True, autoload_with=engine)

query = sa.select([table])

result = cnxn.execute(query)
result = result.fetchall()

# print first entry
print(result[0])

For more details on connection options, check our docs

If you're new to SQLAlchemy, please refer to the SQLAlchemy Unified Tutorial.

Documentation

The documentation for the SQLAlchemy adapter for IBM i can be found at: https://sqlalchemy-ibmi.readthedocs.io/en/latest/

Known Limitations

  1. Non-standard SQL queries are not supported. e.g. "SELECT ? FROM TAB1"
  2. For updations involving primary/foreign key references, the entries should be made in correct order. Integrity check is always on and thus the primary keys referenced by the foreign keys in the referencing tables should always exist in the parent table.
  3. Unique key which contains nullable column not supported
  4. UPDATE CASCADE for foreign keys not supported
  5. DEFERRABLE INITIALLY deferred not supported
  6. Subquery in ON clause of LEFT OUTER JOIN not supported

Contributing to the IBM i SQLAlchemy adapter

Please read the contribution guidelines.

The developer sign-off should include the reference to the DCO in remarks(example below):
DCO 1.1 Signed-off-by: Random J Developer <random@developer.org>

Releasing a New Version

# checkout and pull the latest code from main
git checkout main
git pull

# bump to a release version (a tag and commit are made)
bumpversion release

# To skip a release candidate
bumpversion --no-tag --no-commit release
bumpversion --allow-dirty release

# bump to the new dev version (a commit is made)
bumpversion --no-tag patch

# push the new tag and commits
git push origin main --tags

License

Apache 2.0

Credits

  • ibm_db_sa for SQLAlchemy was first produced by IBM Inc., targeting version 0.4.
  • The library was ported for version 0.6 and 0.7 by Jaimy Azle.
  • Port for version 0.8 and modernization of test suite by Mike Bayer.
  • Port for sqlalchemy-ibmi by Naveen Ram/Kevin Adler.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dt_sqlalchemy_ibmi-2.0.0.dev0.tar.gz (31.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dt_sqlalchemy_ibmi-2.0.0.dev0-py3-none-any.whl (26.1 kB view details)

Uploaded Python 3

File details

Details for the file dt_sqlalchemy_ibmi-2.0.0.dev0.tar.gz.

File metadata

  • Download URL: dt_sqlalchemy_ibmi-2.0.0.dev0.tar.gz
  • Upload date:
  • Size: 31.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.2 CPython/3.10.12 Windows/10

File hashes

Hashes for dt_sqlalchemy_ibmi-2.0.0.dev0.tar.gz
Algorithm Hash digest
SHA256 7a5c603a945c50857fac4f8380a461706f6a62caba5f35b9b2f2cec171ef205a
MD5 49c4caa9e318901709c8d22e60e7632e
BLAKE2b-256 47e509101044fb32eaaec9dc4257dc16849ba871105e317f26935fa1b32fdcb3

See more details on using hashes here.

File details

Details for the file dt_sqlalchemy_ibmi-2.0.0.dev0-py3-none-any.whl.

File metadata

File hashes

Hashes for dt_sqlalchemy_ibmi-2.0.0.dev0-py3-none-any.whl
Algorithm Hash digest
SHA256 6aff65867ffa07ba4986f5c492f0d47b32d89a9a0965293e9dcd503768d098db
MD5 c8fa4bd71b94e716ea577276f8840145
BLAKE2b-256 28980ce0d430a1ecefbe98147d7eca3bcdc0b0f1416f3900ff5d60b8bf1e7cdb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page