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.1.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.1-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dynamic_tables-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 9e6405b6f404a7cd4ced379a2fc7a18933c2a12b6f0ce46121cc86fc433a5080
MD5 7a392a37f291f15f6d1d888772ef7b6e
BLAKE2b-256 2d6260a49e2aaf8e6b06b558abc17dc5b5c910123c551fb26e6703eb9b9a8ccb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dynamic_tables-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 527e50e3b369ca5f3413e4204d60f068c860d4baade48e5ed42db92527fb69bc
MD5 cfd1fc60ae96e8db13d77da856f73c35
BLAKE2b-256 6d9f68106139bb0845c329edc584cd115bef9c17f779018f021d49b5c1e50c39

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