Skip to main content

Experimental psycopg3 driver for pydal

Project description

pydal-psycopg3

pydal-psycopg3 is a proof-of-concept driver for pyDAL, demonstrating integration with psycopg3 as a drop-in replacement for the psycopg2 driver. The goal is to ensure databases relying on psycopg2 functionality can seamlessly transition to psycopg3 while preserving the same driver schemes.

Key Features

  • Drop-In Replacement: The module is designed to work with existing psycopg2 configurations.
  • Custom Scheme Support: Supports both the original "postgres" scheme and a custom "postgres:psycopg3" scheme for explicit usage.
  • Compatibility with pyDAL: Built as a registerable driver, compatible with the DAL object.

Installation

To use this driver, install the package and its dependencies:

(uv) pip install pydal-psycopg3
# or to include the prebuilt driver:
(uv) pip install pydal-psycopg3 psycopg-binary

Getting Started

To integrate pydal-psycopg3, use the following setup:

from pydal import DAL

# Required to register the driver
import pydal_psycopg3

# Using the original scheme
db = DAL("postgres://someuser:somepass@localhost:5432/postgres")

# Or using the explicit psycopg3 scheme
db = DAL("postgres:psycopg3://someuser:somepass@localhost:5432/postgres")

Both approaches ensure the driver works transparently.

Example Usage

  • Define tables and perform queries just like with psycopg2. Here's a minimal example to get started:
# Defining a table
db.define_table("example_table", db.Field("example_field"))

# Inserting data
db.example_table.insert(example_field="test data")
db.commit()

# Querying the table
rows = db(db.example_table).select()
print(rows)

Driver Registration

The driver registers itself automatically when imported and works with either of the following schemes:

  1. postgres:// – The default scheme connects using psycopg3 as the driver.
  2. postgres:psycopg3:// – An explicitly declared scheme to use psycopg3.

Limitations

This module is in its proof-of-concept phase and should be used with caution in production environments. While most functionalities are expected to work as intended, thorough testing is recommended.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydal_psycopg3-0.1.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydal_psycopg3-0.1.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file pydal_psycopg3-0.1.0.tar.gz.

File metadata

  • Download URL: pydal_psycopg3-0.1.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.28.1

File hashes

Hashes for pydal_psycopg3-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7d0f7440600d612d1ae7198181930362bd1f13ef04753b0f6abe611bd093bf6a
MD5 098f50eefc46d1bc48cad9f5eed3e6cf
BLAKE2b-256 728ab1c2840d998772fd9df57a28255b073e3dc4b3fc12a83f88bbb7917747a8

See more details on using hashes here.

File details

Details for the file pydal_psycopg3-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pydal_psycopg3-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2270127d93eafd8d4aaebebbf826f56d4bc19acf12ebbf9bc84a5a8a07873a93
MD5 d8f87f2626b219ba8406d4bd4ab13935
BLAKE2b-256 e82dfadb53001d82f0e225074e00c9cbd0d5c9c3bc634e8729b0cb83c8738017

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page