Skip to content
Peng Ren edited this page Nov 20, 2025 · 19 revisions

PyDynamoDB is a Python DB API 2.0 (PEP 249) client for Amazon DynamoDB. SQLAlchemy dialect supported as well.

Objectives

PyDynamoDB implement the DB API 2.0 interfaces based on PartiQL supported by AWS DynamoDB. Although PartiQL can only support DML operations (INSERT, UPDATE, DELETE, SELECT), PyDynamoDB extended the capabilities to support DDL as well. Now you are able to use MySQL-like statements to CREATE/ALTER/DROP tables. Besides DDL statements, some of utility statements are allowed to execute (Such as, List and Describe Table). PyDynamodb provide parameters and result_set converter to make you easily manipulate operations with Python built-in types. Transaction is also partially supported with DB standard operations, like begin() and commit().

Features

  • Compatible with DB API 2.0 Specification
  • PartiQL for DML operations (INSERT, UPDATE, DELETE, SELECT)
  • Limit supported in SELECT statement
  • Extra type conversion and string functions supported in SELECT statement
  • Column alias supported in SELECT statement
  • MySQL-Like statements for DDL operations (CREATE TABLE, ALTER TABLE, DROP TABLE)
  • MySQL-Like statements for Utility operations (LIST/SHOW TABLES, DESC TABLE)
  • Auto data type conversion for parameters and result set (Including date and datetime)
  • Transaction and Batch operations
  • Dict Resultset provided to support json conversion
  • SQLAlchemy dialect provided
  • Compatible for Superset SQL Lab and graphing

Requirements

  • Python
    • CPython 3.9 3.10 3.11 3.12 3.13 3.14

Dependencies

  • Boto3 (Python SDK for AWS Services)
    • boto3 >= 1.21.0
    • botocore >= 1.24.7
  • Tenacity (Retry Utility for API calling)
    • tenacity >= 4.1.0
  • SQLAlchemy (The ORM Toolkit for Python, only required if using PyDynamoDB Dialect)
    • SQLAlchemy >= 1.0.0
  • Pyparsing (The approach to creating and executing simple grammars)
    • pyparsing >= 3.0.0

Installation

pip install pydynamodb

Run tests with local DynamoDB

Install Local DDB, please see: Deploying DynamoDB locally on your computer. If you want to run tests with local DDB, please make sure environment variables are set properly.

USE_LOCAL_DDB=true
LOCAL_DDB_ENDPOINT_URL=http://localhost:8000
AWS_DEFAULT_REGION=cn-north-1
AWS_ACCESS_KEY_ID=xxxx
AWS_SECRET_ACCESS_KEY=xxxx

Clone this wiki locally