{"id":19977443,"url":"https://github.com/dmickelson/storageserviceproject","last_synced_at":"2026-05-13T03:36:57.453Z","repository":{"id":243239948,"uuid":"763120197","full_name":"dmickelson/StorageServiceProject","owner":"dmickelson","description":"This repository contains the AWSMySQLLib class, which provides a convenient interface to interact with a MySQL database hosted on AWS RDS. The class includes methods for connecting to the database, executing queries, and managing database objects.","archived":false,"fork":false,"pushed_at":"2024-07-07T01:37:53.000Z","size":29,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-12T10:09:16.416Z","etag":null,"topics":["aws","python","rds-database"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dmickelson.png","metadata":{"files":{"readme":"README.MD","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.TXT","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-25T16:02:35.000Z","updated_at":"2024-07-07T01:37:56.000Z","dependencies_parsed_at":"2024-06-07T15:02:54.602Z","dependency_job_id":"1e60f83e-5e3c-48fd-b9d6-c4a7ebb04822","html_url":"https://github.com/dmickelson/StorageServiceProject","commit_stats":null,"previous_names":["dmickelson/storageserviceproject"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmickelson%2FStorageServiceProject","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmickelson%2FStorageServiceProject/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmickelson%2FStorageServiceProject/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmickelson%2FStorageServiceProject/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmickelson","download_url":"https://codeload.github.com/dmickelson/StorageServiceProject/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241411542,"owners_count":19958753,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aws","python","rds-database"],"created_at":"2024-11-13T03:28:04.688Z","updated_at":"2026-05-13T03:36:52.422Z","avatar_url":"https://github.com/dmickelson.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# AWS MySQL Library\n\nThis repository contains the `AWSMySQLLib` class, which provides a convenient interface to interact with a MySQL database hosted on AWS RDS. The class includes methods for connecting to the database, executing queries, and managing database objects.\n\n## Features\n\n- Initialize the connection using configuration from a file.\n- Test connectivity to the AWS RDS host.\n- Connect to the AWS RDS MySQL instance and specific databases.\n- Retrieve information about databases and tables.\n- Create and remove databases and tables.\n- Insert, update, delete, and list records in tables.\n- Manage database connections efficiently.\n- Pytest integration for testing all functionalities.\n\n## Requirements\n\n- Python 3.7+\n- `pymysql` library\n- `configparser` library\n- `socket` library\n- `pytest` library\n- `logging` library\n\n## Installation\n\n1. Clone the repository:\n\n   ```sh\n   git clone https://github.com/yourusername/aws-mysql-lib.git\n   ```\n\n2. Install the required packages:\n\n   ```sh\n   pip install pymysql\n   ```\n\n3. Ensure you have a `logging_storageservice.cfg` configuration file for logging.\n\n## Usage\n\n### Initialization\n\nYou can initialize the `AWSMySQLLib` class either directly by providing the connection details or through a configuration file.\n\n#### Direct Initialization\n\n```python\nfrom awsmysqllib import AWSMySQLLib\n\naws_db = AWSMySQLLib(host='your-host', user='your-username', password='your-password', database='your-database', port=3306)\n```\n\nInitialization from a Configuration File\nCreate a configuration file awsmysql.cfg with the following format:\n\n```\n[AWS_MYSQL_CONFIG]\nhost = your-host\nuser = your-username\npassword = your-password\ndatabase = your-database\nport = 3306\n```\n\nThen, initialize the class:\n\n```\nfrom awsmysqllib import AWSMySQLLib\n\naws_db = AWSMySQLLib.init_from_file('awsmysql.cfg')\n```\n\nMethods\n\n- test_can_reach_host(): Test if the AWS RDS host is reachable.\n- connect_to_rds_host(): Connect to the AWS RDS MySQL instance.\n- connect_to_database(): Connect to the specified database.\n- get_database_info(): Retrieve detailed information about databases.\n- get_database_properties(database_name: str): Retrieve properties of a database.\n- check_database_exists(database_name: str): Check if a database exists.\n- create_database(database_name: str): Create a database.\n- remove_database(database_name: str): Remove a database.\n- create_table(table_name: str, columns: Dict[str, str]): Create a table with the specified columns.\n- list_tables_with_columns(): List all tables within the database with details about their columns.\n- delete_table(table_name: str): Delete a table.\n- list_entries_in_table(table: str): List all entries within a specified table.\n- insert_record(table: str, data: Dict[str, Union[str, int, float]]): Insert a record into the specified table.\n- update_record(table: str, record_id: int, data: Dict[str, Union[str, int, float]]): Update a record in the specified table.\n- delete_record(table: str, record_id: int): Delete a record from the specified table.\n- close_connection(): Close the connection to the MySQL database.\n\n### Example\n\n```\nfrom awsmysqllib import AWSMySQLLib\n\n# Initialize the AWSMySQLLib instance\naws_db = AWSMySQLLib.init_from_file('awsmysql.cfg')\n\n# Test if the host is reachable\nif aws_db.test_can_reach_host():\n    print(\"Host is reachable\")\n\n# Connect to the database\nif aws_db.connect_to_database():\n    print(\"Connected to the database\")\n\n# List tables with their columns\ntables_info = aws_db.list_tables_with_columns()\nprint(tables_info)\n\n# Insert a record into a table\nrecord_id = aws_db.insert_record('example_table', {'name': 'John Doe', 'age': 30})\nprint(f\"Inserted record ID: {record_id}\")\n\n# Close the connection\naws_db.close_connection()\n```\n\n## Testing\n\nThis project includes pytest tests to ensure the library functions as expected. The tests are located in the _tests_ directory and cover all major functionalities of the library.\n\nTo run the tests, use:\n\n```\npytest -sv test_aws_db_connection.py\n```\n\n## Logging\n\nThis library uses Python's built-in logging module. Make sure you have a logging configuration file (logging_storageservice.cfg) set up to capture the logs.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmickelson%2Fstorageserviceproject","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmickelson%2Fstorageserviceproject","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmickelson%2Fstorageserviceproject/lists"}