Product Documentation

FairCom SQL for Python

Previous Topic

Next Topic

SQLAlchemy

SQLAlchemy is one of the most widely used object-relational mapping tools in the Python community. This Python SQL toolkit and Object Relational Mapper gives application developers the full power and flexibility of SQL. The FairCom DB SQL Python interface provides support for this technology. To use this support you will need to install Python 2.7 or 3.0 or higher, SQLAlchemy 1.0, and the FairCom DB SQL Python driver.

If you have an existing application that uses SQLAlchemy, simply install the FairCom DB SQL dialect for SQLAlchemy (as shown in Installing the FairCom DB SQLAlchemy Dialect) to begin taking advantage of the FairCom DB database.

For developers planning a new application and considering SQLAlchemy for its toolkit of SQL abstractions, the FairCom SQLAlchemy support allows you to take advantage of this powerful style of programming.

The FairCom Python interface supports the following versions of SQLAlchemy and Python:

  • SQLAlchemy 1.0 and higher
  • Python 2.7 and Python 3.0 forward

For more about the FairCom Python interface, see the ReadMe provided in the \sdk\sql.python folder (\Driver\sql.python for FairCom RTG).

For more about SQLAlchemy, see their website, https://www.sqlalchemy.org/

Installing the FairCom DB SQLAlchemy Dialect

This package contains the FairCom DB SQL dialect for SQLAlchemy. The dialect enables using FairCom DB SQL with SQLAlchemy, the Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL. More details are available at SQLAlchemy.org.

Note: This driver was specifically developed and tested on SQLAlchemy 1.0.19 with both Python 2.7 and Python 3.5-3.9. It supports SQLAlchemy 1.0 and higher and Python 2.7 and Python 3.0 forward.

Installation

  1. Make sure you have Python 2.7 or 3.0 and higher installed and in your path.
  2. Make sure you have SQLAlchemy 1.0 or higher installed.

    Reminder: setuptools and wheel are prerequisites before SQLAlchemy can be installed on Linux. If you do not have them installed, execute the following before installing SQLAlchemy:
    pip install setuptools
    pip install wheel

  3. Make sure you have the FairCom DB SQL Python driver installed. In a command window, change into the FairCom DB SQL SQLAlchemy dialect folder:

    <faircom>\drivers\python.sql.sqlalchemy

  4. Execute the following command found in the above folder:
    python setup.py install

Windows:

  1. Launch a command prompt as administrator.
  2. Run the following command:

    pip install sqlalchemy

  3. Change to the <faircom>\drivers\python.sql.sqlalchemy directory
  4. Run the following command:

    python setup.py install

Linux:

  1. Bring up a shell.
  2. Run the following command:

    pip3 install sqlalchemy

  3. Change to the <faircom>/drivers/python.sql.sqlalchemy directory
  4. Run the following command:

    python3 setup.py install

If any steps have permission problems, use sudo to run that command.

If step 4 produces the following error, you will need to update your setuptools package:

setuptools_scm.version.SetuptoolsOutdatedWarning: your setuptools is too old (<12)

Un-install the old version of the Python setuptools package and install a later version, as follows:

  • Python 3.x - Install the latest version of setuptools: pip/pip3 install setuptools
  • Python 2.x - Install the last version of setuptools that still supports Python 2.x: pip/pip3 install setuptools==44

After updating setuptools, try step 4 again.

SQL Enhancements

In FairCom DB Python, the following SQL enhancements have been implemented in the Cursor class:

  • iterator
  • lastrowid property

The following enhancements have been implemented in Connection class:

  • support for constructor "port" parameter passed as an integer value
  • support for set_isolation and get_isolation methods

TOCIndex