Skip to main content

Python wrapper for Postgres

Project description

PostQL

PostQL is a Python library and command-line interface (CLI) tool for managing PostgreSQL databases, executing queries, exporting data and interacting with PostgreSQL databases from the command line.

Features

  • Connect to PostgreSQL databases and execute SQL queries interactively via the CLI.
  • Perform database management tasks such as creating, deleting databases, users, tables, etc.
  • Execute SQL queries directly from Python code using the Postgres class.
  • Export query results to CSV, Excel, JSON, and Parquet formats.
  • Upload exported files to Amazon S3 buckets.

Installation

You can install PostQL via pip:

pip install postql

Usage

Command Line Interface (CLI)

To use the PostQL CLI, simply run postql followed by the desired command. Here are some examples:

# Connect to a database and execute SQL queries interactively
postql connect -H localhost -u postgres -P password -d my_database

# Run query
my_database> Select * from my_table

# Exit the CLI
exit

Python Library

from postql import Postgres

# Create a connection to the database
db = Postgres(host="localhost", port="5432", user="postgres", password="password")

# Connect to a specific database
db.connect(database="my_database")

# Execute SQL queries
db.sql("SELECT * FROM my_table")

# Export query results
db.select(table="users") \
    .where({'age': ('>', 25)}) \
    .to_csv("users_result.csv")

Documentation

Contributing

Contributions are welcome! If you find any bugs or have suggestions for improvement, please open an issue or submit a pull request.

The codebase of this project follows the black code style. To ensure consistent formatting, the pre-commit hook is set up to run the black formatter before each commit.

Additionally, a GitHub Action is configured to automatically run the black formatter on every pull request, ensuring that the codebase remains formatted correctly.

Please make sure to run pip install pre-commit and pre-commit install to enable the pre-commit hook on your local development environment.

License

This project is licensed under the MIT License - see the LICENSE for details.

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

PostQL-1.0.1.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

PostQL-1.0.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file PostQL-1.0.1.tar.gz.

File metadata

  • Download URL: PostQL-1.0.1.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for PostQL-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e2f68d6d11fa25a8b568ed2fa00e12abab42e7c5119eaf253cd21144968d87ab
MD5 cfe96975816b2b26aa480d24d925dac9
BLAKE2b-256 5e84f4a71750c6b257726070f00c3330cb64797c031c9c4a9d5703879c4c9d06

See more details on using hashes here.

File details

Details for the file PostQL-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: PostQL-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.10.12

File hashes

Hashes for PostQL-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f37e6620bb3c137836c87716047bc145ed8b79dcfb799a42e5e07785f9fbe772
MD5 80689e44d05241ce4be243fa682fb32e
BLAKE2b-256 7f14be29ec1c57306a0047b09fee19e34c60a0860d5a5af6904671f11ef5c9f5

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