Skip to main content

Package for using multi DBs for Infinity team

Project description

infi-multiDB

Description of your library goes here.

Installation

pip install infi_multi_db

Usage

Here is a simple example of usage

from infi_multi_db import MultiDB

# Replace these values with your actual PostgreSQL connection parameters
connection_params = {
    "dbname": "test",
    "user": "postgres",
    "password": "1234",
    "host": "localhost",
    "port": 5432,
}

# Instantiate the InfiMultyDB with PostgreSQL as the database type
multi_db = MultiDB(db_type="postgresql", connection_params=connection_params)

# Start the connection
multi_db.start_connection()

# Example: Create a table
table_name = "example_table"
columns = [("id", "SERIAL"), ("name", "VARCHAR(255)"), ("age", "INTEGER")]
multi_db.create_table(table_name, columns)

# Example: Insert a record into the table
record_data = {"name": "John Doe", "age": 30}
multi_db.create_record(table_name, record_data)

# Example: Read records from the table
query = "age > 25"
records = multi_db.read_records(table_name, query)
print("Records:", records)
records = multi_db.read_records(table_name, query, ["age"])
print("Records:", records)


# Example: Update a record in the table
record_id_to_update = 1  # Replace with the actual record ID
new_data = {"age": 31}
multi_db.update_record(table_name, record_id_to_update, new_data)

# Example: Read records after update
records_after_update = multi_db.read_records(table_name, query)
print("Records after update:", records_after_update)

# Example: Delete the table
multi_db.delete_table(table_name)

# Stop the connection
multi_db.stop_connection()

Alternatively, you can import DB classes directly and use them. For example:

from infi_multi_db import PostgreSQL

# Replace these values with your actual PostgreSQL connection parameters
connection_params = {
    "dbname": "test",
    "user": "postgres",
    "password": "1234",
    "host": "localhost",
    "port": 5432,
}

# Instantiate the InfiMultyDB with PostgreSQL as the database type
post_db = PostgreSQL(connection_params=connection_params)

# Start the connection
post_db.start_connection()

# Example: Create a table
table_name = "example_table"
columns = [("id", "SERIAL"), ("name", "VARCHAR(255)"), ("age", "INTEGER")]
post_db.create_table(table_name, columns)

# Example: Insert a record into the table
record_data = {"name": "John Doe", "age": 30}
post_db.create_record(table_name, record_data)

# Example: Read records from the table
query = "age > 25"
records = post_db.read_records(table_name, query)
print("Records:", records)
records = post_db.read_records(table_name, query, ["age"])
print("Records:", records)


# Example: Update a record in the table
record_id_to_update = 1  # Replace with the actual record ID
new_data = {"age": 31}
post_db.update_record(table_name, record_id_to_update, new_data)

# Example: Read records after update
records_after_update = post_db.read_records(table_name, query)
print("Records after update:", records_after_update)

# Example: Delete the table
post_db.delete_table(table_name)

# Stop the connection
post_db.stop_connection()

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

infi_multi_db-0.0.4.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

infi_multi_db-0.0.4-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file infi_multi_db-0.0.4.tar.gz.

File metadata

  • Download URL: infi_multi_db-0.0.4.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0

File hashes

Hashes for infi_multi_db-0.0.4.tar.gz
Algorithm Hash digest
SHA256 a82d2282fc958cf82279c648c1fcd6cb5fd470577c22bd6c1e20bb787740c560
MD5 5b8745b62cd04dec9acde17cc9aa221b
BLAKE2b-256 10a4d20c009e8e69a857999582a5dd4ddd300286db732dca65bdb1328f64a1c7

See more details on using hashes here.

File details

Details for the file infi_multi_db-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for infi_multi_db-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 3b7801a108343f04cab076516ade3aee04e430ba6fa5f38ac412777c0da977d0
MD5 dc8f69777a455cf3876565e2a33bb80f
BLAKE2b-256 477dd47fed67e5d5f27f5e3e690b5336f4607878753a2a83b10c11b66a21e1b5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page