The CData Python Connector for DB2 includes a Dialect class that enables integration with SQLAlchemy. The following sections detail various aspects of this integration:
Connecting from SQLAlchemy
See Connecting to construct a URL with which SQLAlchemy loads and uses the appropriate connector automatically.
Querying Data from SQLAlchemy
Querying Data shows how to model DB2 tables with mapped classes and how to use said classes to query the associated tables.
Updating Data from SQLAlchemy
The provider provides INSERT/UPDATE/DELETE functionality in SQLAlchemy via the following methods:
- Updating Data with Sessions demonstrates how to affect the data in the data source by modifying the data in individual instances of the mapped class, adding and deleting instances from a session, and commit all changes with the session object.
- Updating Data with Table Objects shows how to affect the data in the data source by calling the "execute()" method on the session while providing a query constructed by the mapped class's Table object.