Banner
InsertSQLWriter
What is InsertSQLWriter?

InsertSQLWriter is another little utility program that I wrote that allows you to take a tab separated values textfile and output an SQL script for inserting all those values into a table in a database.

 

For example, it would take the file Ingredients.tab (each value is separated by a tab character in the file):

Alkanet Flower 0.10 1
Aloe Vera Leaves 0.10 1
Ambrosia 0.10 2
Apple 0.20 1
Arrowroot 0.10 2
Bergamot Seeds 0.10 1
And output (into a file):
INSERT INTO Ingredients (IngredientName, Weight, Value) VALUES ("Alkanet Flower", 0.10, 1);
INSERT INTO Ingredients (IngredientName, Weight, Value) VALUES ("Aloe Vera Leaves", 0.10, 1);
INSERT INTO Ingredients (IngredientName, Weight, Value) VALUES ("Ambrosia", 0.10, 2);
INSERT INTO Ingredients (IngredientName, Weight, Value) VALUES ("Apple", 0.20, 1);
INSERT INTO Ingredients (IngredientName, Weight, Value) VALUES ("Arrowroot", 0.10, 2);
INSERT INTO Ingredients (IngredientName, Weight, Value) VALUES ("Bergamot Seeds", 0.10, 1);

I found this most useful when trying to get my data out of a Microsoft Access database and into a MySQL one. Access, as far as I know, does not let you export your data directly into SQL, only into a tab separated values file and some other formats.

Again, like ASCIITranslate, I wrote InsertSQLWriter in Pascal to practice it for my University course, which, in first year, uses Pascal to teach people who have no idea how to program how to program.

Download

InsertSQLWriter

InsertSQLWriter is very simple and as such does not need an installer. Just download the executable and run it. Its a simple console application (not DOS).

Version: 1.0.1

Size: 297KB

Download: Here

 

Source Code

The people in my University course may be interested in seeing how I programmed this, so voila, here's the code. Just follow the simple rules: its my code, don't pass it off as your own, and give me credit if you use it.

Version: 1.0.1

Size: 7KB

Download: Here

 

Version History

v1.0.1 - Fixed working directory bug which meant your file was dumped in your home directory, not in the executable's directory.

v1.0.0 - Initial Version

 

System Requirements

Tested on Windows XP. I assume it will run on lower versions of Windows as well although I haven't tested that theory.
The minimum specifications for the computer can be anything as long as the computer can reasonably run the operating system.

How to Use InsertSQLWriter

Firstly, you'll need a tab separated value file to translate. You can get one from any Access table. Some basic settings: make sure values are separated by tabs and that there is no text qualifier eg text is not expressed as "Text", it should be expressed as Text (without the "s).

I'll pinch the data I used in the introduction for this guide (you can download it here):

Alkanet Flower 0.10 1
Aloe Vera Leaves 0.10 1
Ambrosia 0.10 2
Apple 0.20 1
Arrowroot 0.10 2
Bergamot Seeds 0.10 1

That data is saved in a file called Ingredients.tab which is in the same directory as the InsertSQLWriter executable. Each value, although expressed in a table here on this page, is separated by a single tab in the file. Each row in the table is on a separate line.

 

The database table structure for that data is:

Table Name: Ingredients

 

Column Name    | Type

-------------------------

IngredientName | String

Weight         | Number

Value          | Number

So, here are the steps:

1) Drag and drop Ingredients.tab onto InsertSQLWriter.exe

2) Type the table name Ingredients in and press Enter

3) Type in each column (field) name in the order that they are in Ingredients.tab and press Enter between each. So: IngredientName [Enter] Weight [Enter] Value [Enter]

4) Press Enter again to finish the input

5) Type in the data type of each column in the order that they are in Ingredients.tab and press Enter between each. The list displayed onscreen shows the corresponding number for the data type So: 1 [Enter] 2 [Enter] 2 [Enter].

6) Press Enter again to finish the input

7) Enter in the filename that you want the INSERT SQL statements saved into. For this example we'll use Ingredients.sql. So type Ingredients.sql and press Enter to continue. This will create a file called Ingredients.sql in the executable's directory.

8) Thats it!. Press Enter to exit the program and then look at your new outputted file and make sure its OK.

 

For this example your outputted file should look like this:

INSERT INTO Ingredients (IngredientName, Weight, Value) VALUES ("Alkanet Flower", 0.10, 1);
INSERT INTO Ingredients (IngredientName, Weight, Value) VALUES ("Aloe Vera Leaves", 0.10, 1);
INSERT INTO Ingredients (IngredientName, Weight, Value) VALUES ("Ambrosia", 0.10, 2);
INSERT INTO Ingredients (IngredientName, Weight, Value) VALUES ("Apple", 0.20, 1);
INSERT INTO Ingredients (IngredientName, Weight, Value) VALUES ("Arrowroot", 0.10, 2);
INSERT INTO Ingredients (IngredientName, Weight, Value) VALUES ("Bergamot Seeds", 0.10, 1);