{"id":16488831,"url":"https://github.com/austindd/create-sql-rows","last_synced_at":"2026-06-05T22:31:57.045Z","repository":{"id":128179569,"uuid":"166362179","full_name":"austindd/create-sql-rows","owner":"austindd","description":"A small Node.JS application for generating random (but sensible) row values for INSERT INTO statements in SQL syntax, based on user-defined column info.","archived":false,"fork":false,"pushed_at":"2019-01-22T19:54:37.000Z","size":89,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-01-11T18:49:03.664Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/austindd.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":"2019-01-18T07:19:24.000Z","updated_at":"2019-01-22T19:54:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"2a4cd9ea-01ec-4810-ad23-76bceb6f243b","html_url":"https://github.com/austindd/create-sql-rows","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austindd%2Fcreate-sql-rows","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austindd%2Fcreate-sql-rows/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austindd%2Fcreate-sql-rows/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/austindd%2Fcreate-sql-rows/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/austindd","download_url":"https://codeload.github.com/austindd/create-sql-rows/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241314983,"owners_count":19942760,"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":[],"created_at":"2024-10-11T13:40:01.036Z","updated_at":"2026-06-05T22:31:56.986Z","avatar_url":"https://github.com/austindd.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# create-sql-rows\nA small Node.JS tool for generating random (but sensible) row values for INSERT INTO statements in SQL syntax, based on column info that **YOU** define!\n\nThe tool is currently working properly (as far as I know), and I will be adding more features to it periodically.\n\nContributions are welcome!\n\n## How to use it\n\nLet's start with a basic example:\n```js\n'use strict';\nconst  CR  =  require('./module/create-sql-rows.js');\nconst  Path  =  require('path');\n\nconsole.log(`\n _________________\n| GENERATING ROWS |\n|_________________|\n`);\n\n// To use values from the resource-data folder, call 'module.resourceData.loadData()'.\nCR.resourceData.loadData();\n\n// Output file path should include the desired filename:\nconst  outputPath  =  Path.join(__dirname,  './output/user-table-rows.txt');\n\n// Main function:\nCR.generateRows(outputPath, 100, [\n{ name: 'id', datatype: 'int', getValue: CR.incrementInt.next },\n{ name: 'name', datatype: 'varchar', getValue: CR.getRandomVal.name },\n{ name: 'email', datatype: 'text', getValue: CR.getRandomVal.email },\n{ name: 'password', datatype: 'varchar', getValue: CR.getRandomVal.password },\n{ name: 'guid', datatype: 'varchar', getValue: CR.getRandomVal.uuidv4 },\n], {overwriteFile: true, logToConsole: true});\n\n// Output text is now written to './output/user-table-rows.txt'\nconsole.log('~ DONE ~');\n```\nRunning the above code in Node will write 100 rows of text to the specified output file. The result will look like this:\n```\n(1, \"FINLEY\", \"crackpig@example.com\", \"04f2766bf08\", \"7bfc9a70-8e7a-44bc-bd12-c3e648c42f44\"),\n(2, \"EVA\", \"characteristicgoalkeeper@example.com\", \"67d9ad210c12214695b29\", \"a807065d-49e6-415e-b0ba-fdae92b61a41\"),\n(3, \"ROMEO\", \"lootcomplex@example.com\", \"128e84702915bcfc41b6\", \"a74abac6-fe81-4f63-9ea6-aedac25b0213\"),\n(4, \"ELIAS\", \"failisolation@example.com\", \"1a7fc89ec\", \"b9609146-e229-4e4e-8146-96dca409186c\"),\n(5, \"EUGENE\", \"datelunch@example.com\", \"8f65767b10\", \"7e938448-772a-480d-b3f7-f3e0aab0a1dc\"),\n(...), ...\n```\nYou can copy and paste the text file into your SQL query, specifically within the VALUES argument for an INSERT INTO statement.\n\n*Voilà!* Now you can quickly test your SQL schema using realistic data tables!\n\n\n## More Details\n\nAll the functions for this tool are located in  **`./servers/create-sql-rows.js`** file. I suggest importing the module like so:\n```js\n\tconst  CR  =  require('./servers/create-sql-rows.js');\n\tconst  Path  =  require('path');\n```\n\nThe exported module contains **3** main functions/objects:\n```js\n\tmodule.exports = {\n\t\tresourceData: {\n\t\t\ttopFemaleNames = [],\n\t\t\ttopMaleNames = [],\n\t\t\trandomText = [],\n\t\t\trandomWords = [],\n\t\t\tloadData: () =\u003e {...},\n\t\t\treset: () =\u003e {...}\n\t\t},\n\t\tgetRandomVal: {\n\t\t\tname: () =\u003e {...},\n\t\t\ttext: () =\u003e {...},\n\t\t\tword: () =\u003e {...},\n\t\t\temail: () =\u003e {...},\n\t\t\tpassword: () =\u003e {...},\n\t\t\tuuidv4: () =\u003e {...}\n\t\t},\n\t\tgenerateRows: () =\u003e {...};\n\t}\n```\n**`CR.generateRows()`** is the main function for this tool. It takes arguments for the output file path, the number of rows, the column layout, and the types of data to be inserted. The syntax is pretty straight-forward:\n```js\n\t// Note: these are the default argument values\n\tCR.generateRows(\n\t\toutputFilePath = './output/output.txt',\n\t\tnumberOfRows = 1,\n\t\tcols = [\n\t\t\t{name: '', datatype: '', getvalue: () =\u003e {return undefined}, staticValue: undefined},\n\t\t\t... rest\n\t\t],\n\t\toptions = {\n\t\t\tlogToConsole: false,\n\t\t\toverWriteFile: false\n\t\t}\n\t)\n```\nThe other functions in the module allow you to access a pre-defined set of data in the the **`./module.resource-data/`** directory. Here are a few tips to get you started:\n\n* Calling the **`CR.resourceData.loadData()`** method will synchronously load  **`CR.resourceData`** array properties (e.g. **`CR.topMaleNames`** with pre-assembled data. That data is stored within JSON files in the **`.create-sql-rows/module/resource-data`** directory.\n\n* **`CR.getRandomVal`** methods like **`name()`** and **`email()`** take random values from **`CR.resourceData`** arrays and manipulate them to create text output based on common use cases.\n\n* Other tools like **`CR.incrementInt.next()`** offer other, non-random sources of data to populate your rows.\n\n* You can use your own functions to populate the column values if you want. Just keep in mind that **`CR.generateRows`** will call the function passed to the **`getValue`** argument **for each row**, so if you want to pass a particular *sequence* of values to your rows, you should pass a function that iterates through that sequence each time it is called. (I recommend [iterator functions](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators)).\n\n---\n### Dependencies:\n\nBasically none.\n\nThe tool is built for use in a Node environment, and it depends on Node's native `filesystem` and `path` modules for some functionality. No other dependencies are required.\n\nHowever, the core function logic could be slightly adjusted to work with other file system management libraries, as well as other package managers. Just let me know if that is something you want.\n\n---\n\n### Contribute:\n\nFeel free to reach out if you have any suggestions to offer. If you would like to add features or fix any issues, you can submit a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faustindd%2Fcreate-sql-rows","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faustindd%2Fcreate-sql-rows","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faustindd%2Fcreate-sql-rows/lists"}