Name | infi-multi-db JSON |
Version |
0.0.3
JSON |
| download |
home_page | |
Summary | Package for using multi DBs for Infinity team |
upload_time | 2023-12-14 11:26:15 |
maintainer | |
docs_url | None |
author | Infinity Team |
requires_python | |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# infi-multiDB
Description of your library goes here.
## Installation
```bash
pip install infi_multi_db
```
## Usage
Here is a simple example of usage
```python
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:
```python
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()
```
Raw data
{
"_id": null,
"home_page": "",
"name": "infi-multi-db",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Infinity Team",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/5e/4d/e3e7c9ddf2393e4d78f2aba940c4ec9e15fca1382899d81cefd7c63ce129/infi_multi_db-0.0.3.tar.gz",
"platform": null,
"description": "# infi-multiDB\r\n\r\nDescription of your library goes here.\r\n\r\n## Installation\r\n\r\n```bash\r\npip install infi_multi_db\r\n```\r\n\r\n## Usage\r\nHere is a simple example of usage\r\n\r\n```python\r\nfrom infi_multi_db import MultiDB\r\n\r\n# Replace these values with your actual PostgreSQL connection parameters\r\nconnection_params = {\r\n \"dbname\": \"test\",\r\n \"user\": \"postgres\",\r\n \"password\": \"1234\",\r\n \"host\": \"localhost\",\r\n \"port\": 5432,\r\n}\r\n\r\n# Instantiate the InfiMultyDB with PostgreSQL as the database type\r\nmulti_db = MultiDB(db_type=\"postgresql\", connection_params=connection_params)\r\n\r\n# Start the connection\r\nmulti_db.start_connection()\r\n\r\n# Example: Create a table\r\ntable_name = \"example_table\"\r\ncolumns = [(\"id\", \"SERIAL\"), (\"name\", \"VARCHAR(255)\"), (\"age\", \"INTEGER\")]\r\nmulti_db.create_table(table_name, columns)\r\n\r\n# Example: Insert a record into the table\r\nrecord_data = {\"name\": \"John Doe\", \"age\": 30}\r\nmulti_db.create_record(table_name, record_data)\r\n\r\n# Example: Read records from the table\r\nquery = \"age > 25\"\r\nrecords = multi_db.read_records(table_name, query)\r\nprint(\"Records:\", records)\r\nrecords = multi_db.read_records(table_name, query, [\"age\"])\r\nprint(\"Records:\", records)\r\n\r\n\r\n# Example: Update a record in the table\r\nrecord_id_to_update = 1 # Replace with the actual record ID\r\nnew_data = {\"age\": 31}\r\nmulti_db.update_record(table_name, record_id_to_update, new_data)\r\n\r\n# Example: Read records after update\r\nrecords_after_update = multi_db.read_records(table_name, query)\r\nprint(\"Records after update:\", records_after_update)\r\n\r\n# Example: Delete the table\r\nmulti_db.delete_table(table_name)\r\n\r\n# Stop the connection\r\nmulti_db.stop_connection()\r\n```\r\n\r\n# Alternatively, you can import DB classes directly and use them. For example:\r\n\r\n```python\r\nfrom infi_multi_db import PostgreSQL\r\n\r\n# Replace these values with your actual PostgreSQL connection parameters\r\nconnection_params = {\r\n \"dbname\": \"test\",\r\n \"user\": \"postgres\",\r\n \"password\": \"1234\",\r\n \"host\": \"localhost\",\r\n \"port\": 5432,\r\n}\r\n\r\n# Instantiate the InfiMultyDB with PostgreSQL as the database type\r\npost_db = PostgreSQL(connection_params=connection_params)\r\n\r\n# Start the connection\r\npost_db.start_connection()\r\n\r\n# Example: Create a table\r\ntable_name = \"example_table\"\r\ncolumns = [(\"id\", \"SERIAL\"), (\"name\", \"VARCHAR(255)\"), (\"age\", \"INTEGER\")]\r\npost_db.create_table(table_name, columns)\r\n\r\n# Example: Insert a record into the table\r\nrecord_data = {\"name\": \"John Doe\", \"age\": 30}\r\npost_db.create_record(table_name, record_data)\r\n\r\n# Example: Read records from the table\r\nquery = \"age > 25\"\r\nrecords = post_db.read_records(table_name, query)\r\nprint(\"Records:\", records)\r\nrecords = post_db.read_records(table_name, query, [\"age\"])\r\nprint(\"Records:\", records)\r\n\r\n\r\n# Example: Update a record in the table\r\nrecord_id_to_update = 1 # Replace with the actual record ID\r\nnew_data = {\"age\": 31}\r\npost_db.update_record(table_name, record_id_to_update, new_data)\r\n\r\n# Example: Read records after update\r\nrecords_after_update = post_db.read_records(table_name, query)\r\nprint(\"Records after update:\", records_after_update)\r\n\r\n# Example: Delete the table\r\npost_db.delete_table(table_name)\r\n\r\n# Stop the connection\r\npost_db.stop_connection()\r\n\r\n```\r\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Package for using multi DBs for Infinity team",
"version": "0.0.3",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "53e29228094c0e5d43f2a282b63e60a626cb3df0006ef94045f5ce800166139e",
"md5": "7f95f48b2b4928d90f8a30de2e19a1eb",
"sha256": "f477f4eb83c89d9c34a153e18ae0150922bc8be9fd4e7d98bf4409a0ac87cd7c"
},
"downloads": -1,
"filename": "infi_multi_db-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7f95f48b2b4928d90f8a30de2e19a1eb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5942,
"upload_time": "2023-12-14T11:26:13",
"upload_time_iso_8601": "2023-12-14T11:26:13.488518Z",
"url": "https://files.pythonhosted.org/packages/53/e2/9228094c0e5d43f2a282b63e60a626cb3df0006ef94045f5ce800166139e/infi_multi_db-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "5e4de3e7c9ddf2393e4d78f2aba940c4ec9e15fca1382899d81cefd7c63ce129",
"md5": "4e02f2e697e71c5c91343fbcd632693b",
"sha256": "b57bf72a7c97a534b94fe7c3941030cae2011fcfcc8e84e64a8499b9e8fdc038"
},
"downloads": -1,
"filename": "infi_multi_db-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "4e02f2e697e71c5c91343fbcd632693b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5489,
"upload_time": "2023-12-14T11:26:15",
"upload_time_iso_8601": "2023-12-14T11:26:15.101599Z",
"url": "https://files.pythonhosted.org/packages/5e/4d/e3e7c9ddf2393e4d78f2aba940c4ec9e15fca1382899d81cefd7c63ce129/infi_multi_db-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-14 11:26:15",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "infi-multi-db"
}