Skip to main content

A dynamic table creation and management library for PostgreSQL

Project description

Dynamic Tables (Python)

A Python library for dynamically creating and managing PostgreSQL tables based on input data.

🚀 Features

  • Automatically creates tables based on incoming data.
  • Supports dynamic naming conventions.
  • Provides easy database connectivity with PostgreSQL.
  • Includes helper functions for querying and deleting tables.

📥 Installation

1️⃣ Install via GitHub (Recommended for Development)

Clone the repository and install in editable mode:

git clone https://github.com/scottrodeo/dynamic-tables-python.git
cd dynamic-tables-python
pip install -e .

2️⃣ Install Directly via pip

The package is available on PyPI, you can install it with:

pip install dynamic-tables

🏃‍♂️ Running the Example

1️⃣ Quick Run (Without Installation)

If you don't want to install the package, you can directly run the example script:

python3 examples/example.py

💡 This works because the script dynamically adjusts sys.path.

2️⃣ Recommended (After Installation)

If you've installed the package (pip install -e .), simply run:

python3 examples/example.py

📌 Example Usage

Once installed, you can use dynamic_tables in your Python scripts:

from dynamic_tables import DynamicTables

# Initialize the dynamic table manager
tables = DynamicTables()

# Example: Creating and inserting data dynamically
tables.set_table_prefix("dtbl_")
tables.set_columns("domain TEXT, category TEXT, lang TEXT")
tables.set_dynamic_column("domain")

tables.input("wikipedia.org", "cats", "en")
tables.input("wikipedia.org", "dogs", "en")

# Show all tables
tables.show_tables()

🛠️ Available Functions

Function Description
set_columns("name TYPE, age TYPE") Define table schema
set_table_prefix("prefix_") Set a custom table prefix
set_dynamic_column("column_name") Set the column that determines dynamic table names
input(value1, value2, ...) Insert a new row dynamically
show_tables() List all dynamically created tables
show_columns("table_name") Show column details for a specific table
select_table("table_name") Retrieve all rows from a table
delete_tables() Drop all tables matching the prefix

⚡ Development

Running Tests

To run the test suite:

pytest tests/

Linting

Ensure your code follows best practices:

flake8 dynamic_tables/

🤝 Contributing

Contributions are welcome! If you'd like to improve dynamic_tables, follow these steps:

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Commit your changes (git commit -m "Added new feature").
  4. Push to the branch (git push origin feature-branch).
  5. Open a pull request.

📄 License

This project is licensed under the MIT License. See the LICENSE file for details.


🌎 Links


🚀 Happy Coding!

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

dynamic_tables-0.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

dynamic_tables-0.1.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dynamic_tables-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

File hashes

Hashes for dynamic_tables-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ed689703b7729110e8528aad65caecbdda1e74a8974b9845b02b7f184d16a344
MD5 298b15fc74c4ccea8329ce2dfdbeb69d
BLAKE2b-256 9ac7e6716e2d62119842c56170def7e3144ff90df2eb2c478b9f865b7d9226a5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dynamic_tables-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

File hashes

Hashes for dynamic_tables-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 715eb6bee2377bff94408613f4114005ed64e47a431e2c23ee66e535553d3941
MD5 0405651b507e158039410e01a017d0f9
BLAKE2b-256 b9aaa577cee363f9e24a9875ba67f38ede9325daa4589c168c94609b95daeeb1

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