Amazon QLDB driver for Python - Amazon Quantum Ledger Database (Amazon QLDB)

Amazon QLDB driver for Python

To work with data in your ledger, you can connect to Amazon QLDB from your Python application by using an AWS-provided driver. The following topics describe how to get started with the QLDB driver for Python.

Driver resources

For more information about the functionality supported by the Python driver, see the following resources:


Before you get started with the QLDB driver for Python, you must do the following:

  1. Follow the AWS setup instructions in Accessing Amazon QLDB. This includes the following:

    1. Sign up for AWS.

    2. Create an AWS Identity and Access Management (IAM) user with the appropriate QLDB permissions.

    3. Get an IAM access key for development.

  2. Install Python version 3.4 or later from the Python downloads site.

  3. Set up your AWS credentials and your default AWS Region. For instructions, see Quickstart in the AWS SDK for Python (Boto3) documentation.

    For a complete list of available Regions, see Amazon QLDB endpoints and quotas in the AWS General Reference.

Next, you can download the complete tutorial sample application—or you can install only the driver in a Python project and run short code examples.

  • To install the QLDB driver and the AWS SDK for Python (Boto3) in an existing project, proceed to Installation.

  • To set up a project and run short code examples that demonstrate basic data transactions on a ledger, see the Quick start tutorial.

  • To run more in-depth examples of both data and management API operations in the complete tutorial sample application, see the Python tutorial.


QLDB supports the following driver versions and their Python dependencies.

Driver version Python version Status Latest release date
2.x 3.4 or later Production release May 7, 2020
3.x 3.6 or later Production release October 28, 2021

To install the QLDB driver from PyPI using pip (a package manager for Python), enter the following at the command line.

pip install pyqldb
pip install pyqldb==2.0.2

Installing the driver also installs its dependencies, including the AWS SDK for Python (Boto3) and Amazon Ion packages.

Using the driver to connect to a ledger

Then you can import the driver and use it to connect to a ledger. The following Python code example shows how to create a session for a specified ledger name.

from pyqldb.driver.qldb_driver import QldbDriver qldb_driver = QldbDriver(ledger_name='testLedger') for table in qldb_driver.list_tables(): print(table)
from pyqldb.driver.pooled_qldb_driver import PooledQldbDriver qldb_driver = PooledQldbDriver(ledger_name='testLedger') qldb_session = qldb_driver.get_session() for table in qldb_session.list_tables(): print(table)

For short code examples of how to run basic data transactions on a ledger, see the Cookbook reference.