{"id":16183769,"url":"https://github.com/quick-perf/quick-sql-test-data","last_synced_at":"2025-03-19T02:30:52.843Z","repository":{"id":45115130,"uuid":"358210115","full_name":"quick-perf/quick-sql-test-data","owner":"quick-perf","description":"Quickly create your SQL test data","archived":false,"fork":false,"pushed_at":"2022-10-22T09:39:41.000Z","size":204,"stargazers_count":15,"open_issues_count":2,"forks_count":10,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-28T14:08:21.879Z","etag":null,"topics":["code-generator","database","h2","hsqldb","java","mariadb","mssql","mysql","oracle","postgresql","sql","sql-query","tdd","tdd-framework","tdd-sql","tdd-utilities","test","testing"],"latest_commit_sha":null,"homepage":"https://quickperf.io","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quick-perf.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}},"created_at":"2021-04-15T09:57:50.000Z","updated_at":"2024-03-19T20:38:52.000Z","dependencies_parsed_at":"2022-09-14T07:22:12.147Z","dependency_job_id":null,"html_url":"https://github.com/quick-perf/quick-sql-test-data","commit_stats":null,"previous_names":["quick-perf/sql-test-data-generator"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quick-perf%2Fquick-sql-test-data","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quick-perf%2Fquick-sql-test-data/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quick-perf%2Fquick-sql-test-data/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quick-perf%2Fquick-sql-test-data/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quick-perf","download_url":"https://codeload.github.com/quick-perf/quick-sql-test-data/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243960434,"owners_count":20375101,"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":["code-generator","database","h2","hsqldb","java","mariadb","mssql","mysql","oracle","postgresql","sql","sql-query","tdd","tdd-framework","tdd-sql","tdd-utilities","test","testing"],"created_at":"2024-10-10T07:06:45.370Z","updated_at":"2025-03-19T02:30:52.576Z","avatar_url":"https://github.com/quick-perf.png","language":"Java","readme":"# Quick SQL test data\n\n  \u003ca href=\"https://search.maven.org/artifact/org.quickperf/quick-sql-test-data\"\u003e\n    \u003cimg src=\"https://maven-badges.herokuapp.com/maven-central/org.quickperf/quick-sql-test-data/badge.svg\"\n         alt=\"Maven Central\"\u003e\n  \u003c/a\u003e\n  \u0026nbsp;\u0026nbsp;\n  \u003ca href=\"https://github.com/quick-perf/quick-sql-test-data/blob/master/LICENSE.txt\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/license-Apache2-blue.svg\"\n         alt = \"License\"\u003e\n  \u003c/a\u003e\n  \u0026nbsp;\u0026nbsp;\n  \u003ca href=\"https://github.com/quick-perf/quick-sql-test-data/actions?query=workflow%3ACI\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/workflow/status/quick-perf/quick-sql-test-data/CI\"\n         alt = \"Build Status\"\u003e\n  \u003c/a\u003e\n  \u0026nbsp;\n  \u003ca href=\"https://codecov.io/gh/quick-perf/quick-sql-test-data\"\u003e\n    \u003cimg src=\"https://codecov.io/gh/quick-perf/quick-sql-test-data/branch/main/graph/badge.svg?token=U475ES0JIL\"/\u003e\n  \u003c/a\u003e\n\n## Why use *Quick SQL test data*?\nWriting datasets with SQL  may be tedious and time-consuming because of database integrity constraints.\n\n*This Java library aims to ease the generation of datasets to test SQL queries. It produces INSERT statements taking account of integrity constraints.*\n\nThe library automatically:\n* identifies *NOT NULL columns* and provides values by requesting the database\n* adds rows of dependent tables in case of *foreign key constraints*\n* sorts insert statements to accommodate  *foreign key constraints*\n* sorts insert statements following *primary key values*\n\n_[Another project](https://github.com/quick-perf/quick-sql-test-data-web) provides a web page to ease the use of the _Quick SQL test data_ library._\n\n## How to use the library\n\nWith Maven, you have to add the following dependency:\n\n```xml\n\n\u003cdependency\u003e\n    \u003cgroupId\u003eorg.quickperf\u003c/groupId\u003e\n    \u003cartifactId\u003equick-sql-test-data\u003c/artifactId\u003e\n    \u003cversion\u003e0.1\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nYou can generate the insert statements with the help of an instance of `org.qstd.QuickSqlTestData` class.\n\n_Quick SQL test data_ works with:\n* PostgreSQL\n* Oracle\n* MariaDB\n* MySQL\n* Microsoft SQL Server\n* H2\n* HSQLDB\n\n## Use cases\n\nThis library can be helpful in the two following situations.\n\n### Create a dataset before starting the writing of an SQL query\n\nThis case happens when you develop SQL queries with *Test-Driven Development* (TDD).\n\nYou can read below an example where we define a dataset row for which we generate the INSERT statement:\n```java\nQuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(dataSource);\nDatasetRow datasetRow = DatasetRow.ofTable(\"Player\")\n                                  .addColumnValue(\"lastName\",\"Pogba\");\nList\u003cString\u003e insertStatements = quickSqlTestData.generateInsertListFor(datasetRow);\n\nSystem.out.println(insertStatements);\n```\n\nThe console displays the following result:\n```\n[INSERT INTO PLAYER(FIRSTNAME, LASTNAME) VALUES('Paul', 'Pogba')]\n```\nFIRSTNAME column owns a NOT NULL constraint. For this reason, the library has retrieved a FIRSTNAME value for the Pogba LASTNAME and has used it in the generated statement.\n\n### Test an existing SQL query\nLet's take an example:\n\n```java\nQuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(dataSource);\nString selectStatement = \"SELECT * FROM Player WHERE LASTNAME = 'Pogba'\";\nString insertScript = quickSqlTestData.generateInsertScriptFor(selectStatement);\nSystem.out.println(insertScript);\n```\n\nThe console displays the following queries:\n```\nINSERT INTO TEAM(ID, NAME) VALUES(1, 'Manchester United');\nINSERT INTO PLAYER(ID, FIRSTNAME, LASTNAME, TEAM_ID) VALUES(1, 'Paul', 'Pogba', 1);\n```\nThe library has done its best to generate INSERT queries allowing to test the SELECT query.\nIt has detected a foreign key constraint and has generated a first statement inserting on a Team table. This one contains a value for the NAME column that must not be null.\n\n## License\n\n[Apache License 2.0](/LICENSE.txt)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquick-perf%2Fquick-sql-test-data","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquick-perf%2Fquick-sql-test-data","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquick-perf%2Fquick-sql-test-data/lists"}