Skip to main content

A Python package from the DS library collection

Project description

ds-provider-postgresql-py-lib

A PostgreSQL provider for the DS resource plugin ecosystem.

Installation

pip install ds-provider-postgresql-py-lib

Features

  • PostgreSQL linked service with connection pooling and health checks.
  • PostgreSQL dataset implementation with support for:
    • read()
    • create()
    • update()
    • upsert()
    • delete()
    • purge()
  • DS resource typing via:
    • ds.resource.linked_service.postgresql
    • ds.resource.dataset.postgresql

Usage

Public exports

from ds_provider_postgresql_py_lib import (
    PostgreSQLDataset,
    PostgreSQLDatasetSettings,
    PostgreSQLLinkedService,
    PostgreSQLLinkedServiceSettings,
    __version__,
)

Minimal linked service example

import os
import uuid

from ds_provider_postgresql_py_lib import (
    PostgreSQLLinkedService,
    PostgreSQLLinkedServiceSettings,
)

linked_service = PostgreSQLLinkedService(
    id=uuid.uuid4(),
    name="postgres-linked-service",
    version="1.0.0",
    settings=PostgreSQLLinkedServiceSettings(
        uri=os.getenv("DATABASE_URI", ""),
    ),
)

linked_service.connect()
ok, message = linked_service.test_connection()
print(ok, message)

Minimal dataset read example

import os
import uuid

from ds_provider_postgresql_py_lib import (
    PostgreSQLDataset,
    PostgreSQLDatasetSettings,
    PostgreSQLLinkedService,
    PostgreSQLLinkedServiceSettings,
)
from ds_provider_postgresql_py_lib.dataset.postgresql import ReadSettings

dataset = PostgreSQLDataset(
    id=uuid.uuid4(),
    name="postgres-dataset",
    version="1.0.0",
    linked_service=PostgreSQLLinkedService(
        id=uuid.uuid4(),
        name="postgres-linked-service",
        version="1.0.0",
        settings=PostgreSQLLinkedServiceSettings(
            uri=os.getenv("DATABASE_URI", ""),
        ),
    ),
    settings=PostgreSQLDatasetSettings(
        schema="public",
        table="test",
        read=ReadSettings(limit=10),
    ),
)

dataset.linked_service.connect()
dataset.read()
print(dataset.output)

Requirements

  • Python 3.11+
  • See pyproject.toml for the full dependency set.

Documentation

Development

git clone https://github.com/grasp-labs/ds-provider-postgresql-py-lib.git
cd ds-provider-postgresql-py-lib
uv sync --all-extras --dev
make test

License

Apache-2.0. See LICENSE-APACHE.

Support

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

ds_provider_postgresql_py_lib-0.1.0b2.tar.gz (21.2 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file ds_provider_postgresql_py_lib-0.1.0b2.tar.gz.

File metadata

File hashes

Hashes for ds_provider_postgresql_py_lib-0.1.0b2.tar.gz
Algorithm Hash digest
SHA256 9ec99f85b91a69f17fbab88b3bec67077e70556077b0d0a5f0ec812142a89f41
MD5 34267e5ff06029bedd40a6f655a3f116
BLAKE2b-256 f71ddeadcfaebf10abe9930db0ee7c9608ecf7146a51dbb5d136d70316cac99d

See more details on using hashes here.

File details

Details for the file ds_provider_postgresql_py_lib-0.1.0b2-py3-none-any.whl.

File metadata

File hashes

Hashes for ds_provider_postgresql_py_lib-0.1.0b2-py3-none-any.whl
Algorithm Hash digest
SHA256 6e7ae5bee90ddf4855a5df0c4d91a8bb6cc9d67c50fe1b1cbd8569b91f3f0fa4
MD5 4e3758a6924dd28e624ca856fe4143ce
BLAKE2b-256 b9d3b594a8cf0d3849f7aac81fceb96ddc09919c5c37d5c1b0beef3c1d4233a2

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