[ Web Proxy ]
URL:
Viewing: https://docs.cloud.google.com/spanner/docs/use-sqlalchemy [Back]  [Original]

Integrate Spanner with SQLAlchemy ORM (GoogleSQL dialect)  |  Google Cloud Documentation Skip to main content
Google Cloud Documentation [Google Cloud Documentation]
Send feedback

Integrate Spanner with SQLAlchemy ORM (GoogleSQL dialect) Stay organized with collections Save and categorize content based on your preferences.

SQLAlchemy is a Python SQL toolkit and Object Relational Mapper.

The Spanner dialect for SQLAlchemy lets SQLAlchemy users to use Spanner databases. The dialect is built on top of the Spanner API, which is designed in accordance with PEP-249, and is compatible with SQLAlchemy versions between 1.1.13 and 1.3.23, and 2.0.

PostgreSQL interface note: To use PostgreSQL interface for Spanner with SQLAlchemy, see Integrate Spanner with SQLAlchemy 2 ORM (PostgreSQL-dialect).

Set up the Spanner dialect for SQLAlchemy

To set up the Spanner dialect for SQLAlchemy in your application, install the sqlalchemy-spanner package.

pip3 install sqlalchemy-spanner

Alternatively, you can install from source.

git clone https://github.com/googleapis/google-cloud-python.git
cd google-cloud-python/packages/sqlalchemy-spanner
python setup.py install

As authentication for the Spanner dialect for SQLAlchemy, provide the service account JSON credentials file location in the GOOGLE_APPLICATION_CREDENTIALS environment variable. Otherwise, the dialect can also use the default credentials set in the gcloud CLI application.

Use the Spanner dialect for SQLAlchemy

For more information about the available features, limitations of the dialect, recommendations on how to use the dialect, and for code samples, please consult the reference documentation on GitHub.

What's next

Send feedback

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-08-11 UTC.

Need to tell us more? [[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2026-08-11 UTC."],[],[]]

Web Proxy Viewer  |  New URL  |  Original Page