Skip to main content

Functionality to connect and interact with PostgreSQL servers

Project description

pypSQL

pypsql utilities website

License: MIT

pypsql is a lightweight framework for connecting to PostgreSQL databases, whether locally or remotely hosted. It builds on top of SQLAlchemy to provide a simple, Pythonic interface for establishing connections, running queries, and managing database sessions.

Contributors

Marius Liebald (maintainer)

Installation

pip install pypsql

Basic Usage

Provide database credentials

You can store the database connection details in a file, for example:

server=<host name or address>   # e.g., localhost, 127.0.0.1, or a public IP
port=<port number>              # default: 5432
name_database=<database name>   # e.g., my_db
name_user=<role>                # e.g., Alice
password_user=<password>        # e.g., 123abc

You may place this file anywhere on the client machine. Importantly, this step is optional. You can also provide the variables interactively via terminal prompts.

No SSH required

An SSH tunnel is not needed if:

  • the server and client run on the same machine,
  • the server and client are in the same (virtual) network, or
  • the server is accessible via its public IP.

In this case, simply run the Python script:

import pypsql
from pathlib import Path

conn = pypsql.DatabaseConnector(
    path=Path(<path to the credential file>), # e.g., "/Users/marius/Desktop/"
    db_credential_file=<name of credential file>   # e.g., "credentials.py"
)

sql_script = """
SELECT *
FROM customers
"""

df = conn.get_data(sql_script)

print(df)

Note that this example assumes the database contains a table named customers.

Connection via SSH

To be filled.

Official Documentation

The documentation is hosted under https://www.marius-liebald.com/pypsql/index.html

License

The package is distributed under the MIT license.

References

Bayer, Michael, and contributors. 2025. “SQLAlchemy.” https://www.sqlalchemy.org/.

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

pypsql-0.0.2a0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

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

pypsql-0.0.2a0-py3-none-any.whl (10.1 kB view details)

Uploaded Python 3

File details

Details for the file pypsql-0.0.2a0.tar.gz.

File metadata

  • Download URL: pypsql-0.0.2a0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for pypsql-0.0.2a0.tar.gz
Algorithm Hash digest
SHA256 dd82443cd95f5f1fd3e48345ba394e129d38205a76c4899a5dcee4a07cff6995
MD5 2b29b089f85ba7edd6d7348413c6bc85
BLAKE2b-256 01006f733a1ddc67e6a7b36c6fdce2178da225cded8a5a1d1bdeabaf57f90f12

See more details on using hashes here.

File details

Details for the file pypsql-0.0.2a0-py3-none-any.whl.

File metadata

  • Download URL: pypsql-0.0.2a0-py3-none-any.whl
  • Upload date:
  • Size: 10.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for pypsql-0.0.2a0-py3-none-any.whl
Algorithm Hash digest
SHA256 3fd4351c949056e949faed6f6c42b248d15fe1770bcc5b23e74beb0e07f9725f
MD5 fb3d6ad497a1b47afd0051994574f2b9
BLAKE2b-256 551fac604d5bb964b023563e39a518c4b27baf42d6be400f17a0c2e6de094e36

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