{"id":14972180,"url":"https://github.com/sfneal/mysql-toolkit","last_synced_at":"2025-10-07T10:49:42.976Z","repository":{"id":57444588,"uuid":"152088941","full_name":"sfneal/mysql-toolkit","owner":"sfneal","description":"Syntax free MySQL toolkit... Build sophisticated queries programmatically, no need for tedious string manipulation.  Handle's a remote MySQL database connection with a context manager, call almost any SQL query through a single import.  Execute large SQL script (100mb+) on remote database, automatic command recognition, separation, and sequential execution.","archived":false,"fork":false,"pushed_at":"2024-05-06T16:41:15.000Z","size":41251,"stargazers_count":9,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-30T08:51:18.872Z","etag":null,"topics":["manipulation","mysql","mysql-database","python","sql","sqlparse"],"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/sfneal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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":"2018-10-08T13:57:22.000Z","updated_at":"2024-09-18T20:08:42.000Z","dependencies_parsed_at":"2024-05-06T18:08:55.320Z","dependency_job_id":null,"html_url":"https://github.com/sfneal/mysql-toolkit","commit_stats":{"total_commits":518,"total_committers":3,"mean_commits":"172.66666666666666","dds":0.007722007722007707,"last_synced_commit":"f0b3bc5f3ad8a8818ea26c0d5ce8b2b1bba0755e"},"previous_names":["mrstephenneal/mysql-toolkit"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/sfneal/mysql-toolkit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfneal%2Fmysql-toolkit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfneal%2Fmysql-toolkit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfneal%2Fmysql-toolkit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfneal%2Fmysql-toolkit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sfneal","download_url":"https://codeload.github.com/sfneal/mysql-toolkit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sfneal%2Fmysql-toolkit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278762921,"owners_count":26041444,"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","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["manipulation","mysql","mysql-database","python","sql","sqlparse"],"created_at":"2024-09-24T13:46:30.349Z","updated_at":"2025-10-07T10:49:42.943Z","avatar_url":"https://github.com/sfneal.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MySQL-toolkit\n\n[![GuardRails badge](https://badges.production.guardrails.io/mrstephenneal/mysql-toolkit.svg)](https://www.guardrails.io)\n\nDevelopment toolkit for building applications that interact with a MySQL database.\n\n## Getting Started\n\nThese instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.\n\n### PyPi installation\n\nPyPi distribution\n\n```\npip install mysql-toolkit\n```\n\n## Usage\n\nMySQL-tookit aims to provide an easy to use MySQL dependency that allows developers to integrate MySQL database's with their Python applications.\n\nThe entire MySQL-toolkit module can be utilized through a single import.  To initialize a MySQL instance, simply provide a dictionary of MySQL database connection parameters with your call to MySQL within a context manager.  Wrap all method and property calls with a context manager in order to automate connecting a disconnecting to a database.\n\n```python\nfrom mysql.toolkit import MySQL\n\n# Database connection parameters\nconfig = {\n    \"database\": \"xxxnameofyourdatabasexxx\",\n    \"host\": \"xxxhosturlxxx\",\n    \"password\": \"xxxyourpasswordxxx\",\n    \"port\": xxxhostportxxx,\n    \"raise_on_warnings\": true,\n    \"user\": \"xxxyourusernamexxx\"\n}\n\n# Establish a connection and execute queries\nwith MySQL(config) as sql:\n\t# Select all rows from 'tablename'\n\tresults = sql.select_all('tablename')\n\t\n\t# Update the row in 'anothertable' where the column 'id' equals 20421\n\tsql.update('anothertable', ['column1', 'column2'], ['value1', 2], ('id', 20421)\n\t\n\t# Retrieve a dictionary containing table, row_count key/values for every table in the database\n\tcounts = sql.count_rows_all()\n\n# Query will fail and raise an error because the database connection is only maintained inside with context\ntables = sql.tables()  # Retrieve all tables in the database\n```\n\n## User API\nThe MySQL class's methods are broken down into several categories and inherited via sub-modules.  All methods (with a few exceptions) are inherited to the core MySQL class, exposing compiled methods through a single class.\n\n### Manipulate\nSQL commands that deal with the manipulation of data present in database.\n\n| Class | Method | Description |\n| --- | --- | --- |\nSelect | select_all | Query all rows and columns from a table\nSelect | select_distinct | Query distinct values from a table\nSelect | select | Query every row and only certain columns from a table\nSelect | select\\_all_join (coming soon) | Left join all rows and columns from two tables where a common value is shared\nSelect | select_limit | Run a select query with an offset and limit parameter\nSelect | select_where | Query certain columns from a table where a particular value is found\nInsert | insert_uniques | Insert multiple rows into a table that do not already exist\nInsert | insert | Insert a single row into a table\nInsert | insert_many | Insert multiple rows into a table\nUpdate | update | Update the values of a particular row where a value is met\nUpdate | update_many | Update the values of several rows\nDelete | delete | Delete existing rows from a table\n\n\n### Operations\nSQL commands that deal with the definitions of data present in database.\n\n| Class | Method | Description |\n| --- | --- | --- |\nOperations | backup_database | Create a backup of a database\nOperations | create_table | Generate and execute a create table query by parsing a 2D dataset\nOperations | execute_script | Wrapper method for SQLScript class\nOperations | script | Wrapper method providing access to the SQLScript class's methods and properties\nClone | copy_database | Copy a database's content and structure\nCompare | compare_dbs | Compare the tables and row counts of two databases\nCompare | compare_schemas | Compare the structures of two databases\nCompare | compare_data | Compare the data stored in two databases\nRemove | truncate | Empty a table by deleting all of its rows\nRemove | truncate_database | Drop all tables in a database\nRemove | drop | Drop a table from a database\nRemove | drop_empty_tables | Drop all empty tables in a database\nRemove | truncate | Empty a table by deleting all of its rows\n\n\n#### Structure\nProperties and methods that return metadata about a MySQL table(s).\n\n| Class | Method | Description |\n| --- | --- | --- |\nStructure | tables | Retrieve a list of tables in the connected database\nStructure | databases | Retrieve a list of databases that are accessible under the current connection\nStructure | get\\_unique\\_column | Determine if any of the columns in a table contain exclusively unique values\nStructure | count\\_rows\\_duplicates | Get the number of rows that do not contain distinct values\nStructure | count\\_rows\\_all | Get the number of rows for every table in the database\nStructure | count_rows | Get the number of rows in a particular table\nStructure | count\\_rows\\_all | Get the number of rows for every table in the database\nStructure | count\\_rows\\_all\\_distinct | Get the number of distinct rows for every table in the database\nStructure | count\\_rows\\_distinct | Get the number distinct of rows in a particular table\nStructure | get\\_duplicate\\_vals | Retrieve duplicate values in a column of a table\nAlter | add_column | Add a column to an existing table\nAlter | drop_column | Remove a column to an existing table\nAlter | add_comment | Add a comment to an existing column in a table\nPrimaryKey | get\\_primary\\_key\\_vals | Retrieve a list of primary key values in a table\nPrimaryKey | get\\_primary\\_key | Retrieve the column which is the primary key for a table\nPrimaryKey | set\\_primary\\_key | Create a Primary Key constraint on a specific column when the table is already created\nPrimaryKey | set\\_primary\\_keys\\_all | Create primary keys for every table in the connected database\nPrimaryKey | drop\\_primary\\_key | Drop a Primary Key constraint for a specific table\nForeignKey | set\\_foreign\\_key | Create a Foreign Key constraint on a column from a table\nDefinition | get\\_table\\_definition | Retrieve a CREATE TABLE statement for an existing table\nDefinition | get\\_column\\_definition\\_all | Retrieve the column definition statement for a column from a table\nDefinition | get\\_column\\_definition | Retrieve the column definition statement for a column from a table\nSchema | show_schema | Print schema information\nSchema | get_columns | Retrieve a list of columns in a table\nSchema | get_schema\\_dict | Retrieve the database schema in key, value pairs for easier references and comparisons\nSchema | get_schema | Retrieve the database schema for a particular table\n\n\n## Built With\n\n* [differentiate](https://github.com/mrstephenneal/differentiate) - Compare multiple data sets and retrieve the unique, non-repeated elements.\n* [mysql-connector](https://dev.mysql.com/doc/connector-python/en/) - Self-container driver for communication with MySQL servers\n* [looptools](https://github.com/mrstephenneal/looptools) - Logging output, timing processes and counting iterations\n* [sqlparse](https://github.com/andialbrecht/sqlparse) - A non-validating SQL parser module for Python\n* [tqdm](https://github.com/tqdm/tqdm) - A fast, extensible progress bar for Python\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](https://github.com/mrstephenneal/mysql-toolkit/contributing.md) for details on our code of conduct, and the process for submitting pull requests to us.\n\n## Versioning\n\nWe use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/mrstephenneal/mysql-toolkit).\n\n## Authors\n\n* **Stephen Neal** - *Initial work* - [mysql-toolkit](https://github.com/mrstephenneal/mysql-toolkit)\n\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsfneal%2Fmysql-toolkit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsfneal%2Fmysql-toolkit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsfneal%2Fmysql-toolkit/lists"}