{"id":22018147,"url":"https://github.com/rvflash/shdb","last_synced_at":"2026-04-29T20:34:38.098Z","repository":{"id":146848681,"uuid":"46588793","full_name":"rvflash/shdb","owner":"rvflash","description":"Bash command to improve dump / load tables with or without default datas on MySql database","archived":false,"fork":false,"pushed_at":"2016-10-11T11:53:29.000Z","size":82,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"stable","last_synced_at":"2025-10-14T17:48:45.353Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rvflash.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2015-11-20T21:52:25.000Z","updated_at":"2017-04-29T15:15:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"2293c440-d291-4c00-a79e-806e3d695c6f","html_url":"https://github.com/rvflash/shdb","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/rvflash/shdb","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvflash%2Fshdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvflash%2Fshdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvflash%2Fshdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvflash%2Fshdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rvflash","download_url":"https://codeload.github.com/rvflash/shdb/tar.gz/refs/heads/stable","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rvflash%2Fshdb/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32443563,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-29T20:22:27.477Z","status":"ssl_error","status_checked_at":"2026-04-29T20:22:26.507Z","response_time":110,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2024-11-30T05:10:10.934Z","updated_at":"2026-04-29T20:34:38.078Z","avatar_url":"https://github.com/rvflash.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# shdb\n\nBash command line tools to dump or load MySql table's structure or data.\n\n\u003e Create a folder by database and one folder by table inside.\n\u003e Enable re-building or not, to prevent overloading.\n\u003e Remove \"DROP TABLE\" in SQL file, add \"IF EXISTS\" on table and replace \"INSERT\" by \"INSERT IGNORE \n\n\n## About\n\nDeveloped to provide methods to save in a GIT repository the structure and default data of MySql tables.\nIn order that this deposit is also readable by a human being, the storage respects the following naming convention:\n\n```bash\n\u003e DATABASE_NAME\n\u003e   - TABLE_NAME\n\u003e       |_ table.sql\n\u003e       |_ data.sql\n```\n\n`table.sql` contains the table's structure and `data.sql`, the data to insert on it.\nIn order to manage various project, it is possible to force the name of data's files.\n\nFor example, this structure offers possibility to remove a specific table on an existing database by overwrite its file with drop table query.\n\n\n## Required\n\nmysql \u0026 mysqldump command line tools\n\n\n### Dump: export one, more or all tables from a database.\n\nIt is possible to make several databases simultaneously, but surely of little use in a production environment.\n\n```bash\nusage: ./dump.sh -d databases [-t tables] [-h host] [-u user] [-p password] [-b backupDirectory] [-f sqlFileName] [-w whereCondition] [-v] [-D] [-T] [-A]\n-d for database name(s), separated by a space\n-t for table name(s), separated by a space\n-h for database hostname, default 'localhost'\n-u for database username, default 'mysql'\n-p for database password, default ''\n-b for backup folder path\n-f to name sql data file, default 'datas.sql'\n-w for limit rows selected by the given WHERE condition\n-v used to print SQL Query\n-D for export data with schema\n-T for keep TMP tables, by convention named with '_' as first letter or with '_TMP' on the name\n-A for keep auto-increment value\n```\n\n\n### Load: import one, more or all tables in one or more databases\n\n```bash\nusage: ./load.sh -b rootRepository [-d databases] [-t tables] [-h host] [-u user] [-p password] [-f sqlFileNames] [-v] [-r] [-B]\n-b for root repository with SQL files\n-d for database name(s), separated by a space\n-t for table name(s), separated by a space\n-h for database hostname, default 'localhost'\n-u for database username, default 'mysql'\n-p for database password, default ''\n-f for sql file name(s) with data to load, separated by a space\n-r for launch a dry-run, see result without apply it on database\n-v for verbose mode\n-B to force re-build (drop table, etc.)\n```\n\n#### Prevent the re-building of data and structure\n\nApply the following change on SQL to load:\n\n* Remove `DROP TABLE`\n* Replace `CREATE TABLE` by `CREATE TABLE IF NOT EXISTS`\n* Replace `INSERT INTO` by `INSERT IGNORE INTO`\n\n#### Dry-run\n\nYou also can launch a dry-run to see all the SQL queries before load it on database:\n\n```bash\n./load.sh -b \"/tmp/shdb\" -r -d \"test\" -B\nLoad test [++++++++++++++++++++] 100%\n\nDROP TABLE IF EXISTS `rv`;\nCREATE TABLE `rv` (\n  `id` int(10) unsigned NOT NULL,\n  `name` varchar(255) NOT NULL,\n  PRIMARY KEY (`id`)\n) ENGINE=InnoDB DEFAULT CHARSET=latin1;\n\nINSERT IGNORE INTO `rv` (`id`, `name`) VALUES (1,'Hello'),(2,'World');\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frvflash%2Fshdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frvflash%2Fshdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frvflash%2Fshdb/lists"}