tX.tDataStore PostgreSQL helper package for common database operations.
Project description
ticrobe.pgsql
Python package for PostgreSQL database operations.
Published package name: ticrobe.pgsql
Version: 26.4.1
Install
pip install ticrobe.pgsql
For local development from this workspace:
pip install -e .
Build and upload to PyPI
Build from inside tX.tPgSql:
python -m pip install --upgrade pip build twine
python -m build
python -m twine check dist/*
Upload using a PyPI API token:
python -m twine upload -u __token__ -p pypi-YOUR_API_TOKEN dist/*
Important:
- In
twine, the "password" is your PyPI API token - The username should be exactly
__token__ - The package files are generated in
tX.tPgSql/dist/
Quick start
from ticrobe.pgsql import DatabaseConfig, PostgresDB
config = DatabaseConfig(
host="localhost",
port=5432,
database="mydb",
schema="public",
user="postgres",
password="secret",
)
with PostgresDB(config) as db:
db.create_table(
"users",
{
"id": "SERIAL PRIMARY KEY",
"name": "VARCHAR(100) NOT NULL",
"email": "VARCHAR(255) UNIQUE NOT NULL",
"created_at": "TIMESTAMP DEFAULT CURRENT_TIMESTAMP",
},
)
db.insert("users", {"name": "Asha", "email": "asha@example.com"})
db.update(
"users",
{"name": "Asha R"},
"email = %s",
["asha@example.com"],
)
rows = db.fetch_all("SELECT * FROM users ORDER BY id")
db.delete("users", "email = %s", ["asha@example.com"])
You can also load connection settings from PostgreSQL environment variables:
config = DatabaseConfig.from_env()
Supported environment variables include PGHOST, PGPORT, PGDATABASE, PGSCHEMA,
PGUSER, PGPASSWORD, and PGCONNECT_TIMEOUT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ticrobe_pgsql-26.4.1.tar.gz.
File metadata
- Download URL: ticrobe_pgsql-26.4.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1165a54126798c4b1d3712460f092d73aa5b6fc7bb84c4a3edeeaf65d5f4dca5
|
|
| MD5 |
91a9180667e8645b7a8883f8c68f3fa8
|
|
| BLAKE2b-256 |
d312f8c120fe11f973c28ef0697042a75dc0349905e4e132b5c7d094f335d351
|
File details
Details for the file ticrobe_pgsql-26.4.1-py3-none-any.whl.
File metadata
- Download URL: ticrobe_pgsql-26.4.1-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55b5b4fa06d146fd6131ffaefa0011183a4828634f58b0b25fad2526a80b5f39
|
|
| MD5 |
ed8053d0b4ca7a09c93c41ea69fe05b8
|
|
| BLAKE2b-256 |
4d3cdc235683ecf0b77f7a60861d23ad069a54b294eb4ead7f5fcc86dd9da5d2
|