Skip to content

Commit 9f1cfd2

Browse files
authored
Update README.md
1 parent 1ca840c commit 9f1cfd2

File tree

1 file changed

+65
-1
lines changed

1 file changed

+65
-1
lines changed

README.md

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,66 @@
1-
# mysql-excel-data-administrator
1+
# MySQL data administrator made in Excel
22
Excel which allows to administrate data for MySQL tables (or MariaDB, for example)
3+
4+
Intro
5+
6+
I think that the "MySQL Workbench" is a great tool for managing tables, table diagrams (relations), indexes, views and other objects, but populating and managing data is the nightmere there, due to some bugs and not-so-friendy user interface.. so I created an Excel document just for that
7+
8+
Use cases
9+
10+
1. if you want to load data (import) into some "MySQL Workbench" table
11+
2. if you want to create INSERT statements for "PhpMyAdmin"
12+
13+
In both of the cases - you will be managing data in Excel document directly.
14+
This is the tool that I have created for a personal use and I never use option 1. So some limitations are applied there.
15+
16+
How to use
17+
18+
Generating the output file
19+
20+
In case 1.
21+
open Excel
22+
set "file name"
23+
set "file extension" to "csv"
24+
set "use SQL statement.." to "No"
25+
click on "Generate file" button
26+
27+
In case 2.
28+
set "file name"
29+
set "file extension" to "txt"
30+
set "use SQL statement.." to "Yes"
31+
click on "Generate file" button
32+
33+
A new file will be created in the same directory, where Excel file is. The file can then be imported in MySQL workbench (for different tables you shall create different files!!), or you can run all SQL inserts in PhpMyAdmin, for example.
34+
35+
Creating worksheets (tables)
36+
37+
The problem is that you have to know exact columns that you have in tables, when populating the data in Excel. So I created a helper button, which will generate the new "Worksheet" in Excel, along with column names. So you have a metter managing capabilities.
38+
39+
go to "Mysql Workbench"
40+
go to diagram view of your table
41+
right click on table and use the option called "Copy Insert Template to Clipboard"
42+
open Excel document
43+
paste the insert template into field "Insert statement"
44+
click on "Add Worksheet(Table)" button
45+
46+
P.S.: In Workbench button "Copy Insert Template to Clipboard" always generates data in format:
47+
INSERT INTO `DATABASE`.`TABLE` (`COLUMN1`, `COLUMN2`, ...) VALUES (NULL, NULL, NULL, ...);
48+
So if you for some reason can not use the Workbench - you can either create Excel worksheets yourself (using the conventions below OR create an insert statement template youself.
49+
50+
Conventions
51+
52+
Excel shall always have a "main" worksheet and it shall be first in the list
53+
Worksheet (non-main) should have the matching name with the table name in order to generate data correctly
54+
In non-main worksheet - row 1 can have a value: NUMBER. This will force to not-use single quote for the generated value
55+
In non-main worksheet - row 2 is the default value for data wors. So if you are not specifying any values in data rows -> the default value will be taken from "row 2"
56+
In non-main worksheet - row 3 are just column names in MySQL table. This is only for your own convenience. It has no affect to anything.
57+
In non-main worksheet - row 4+. These are rows with your data.
58+
For all data rows where you are not putting "NUMBER" in row 1 - the script will automatically enclose the value in single quote characters
59+
Is you are using a double quote in your data cell value - it will automatically escape using the \ symbol so " will become \"
60+
61+
62+
If you are a developer who wants to contribute to the project - after you change the VBA in Excel itself - don't forget to export VBA module into a sepaarte BAS file and commit it as well, so we keep the track of changes.
63+
64+
65+
66+

0 commit comments

Comments
 (0)