This program is a C-based command-line tool for constructing basic DML SQL queries from .csv.
My main motivation for building this tool was to learn the basics of the C programming language in a practical way. It also doesn't hurt to have a tool that can build testable mock data sets quickly.
- Clone csv2sql repository into local directory
- Run cmd in directory containing cloned csv2sql repository
- Enter command in terminal to generate program executable: gcc main.c -o csv2sql.exe
- Enter command in terminal to run csv2sql program: csv2sql
INSERT Query
- I,-,table,-,value,-
- I,-,table,-,value1,value2,-
- I,-,table,-,column1,column2,-,value1,value2,-
UPDATE Query
- U,-,table,-,column,-,value,-,refColumn,-,refValue,-
DELETE Query
- D,-,table,-,refColumn,-,refValue,-
In addition to above examples:
- There should be no empty lines between data rows
- Data within row should be sepereated by ‘-‘ character
- Datatype must be specified in .csv (example: 'dataExample')
See example files in csv2sql Test directory
- To test csv2sql.exe with bigger sample, enter command in terminal: csv2sql < test/test_input.csv
- To test using your own data, please follow directions below.
- Install csv2sql tool (see installation directions)
- Verify your input file only contains accepted .csv data format (see formatting rules above)
- Run command to generate .sql file from .csv: csv2sql < your_input_file.csv > your_output_file.sql
- Verify output .sql file in your local directory
If you wish to contribute to this project, please generate a pull request for review. Comments are also always much welcomed. Thank you!