Skip to content

Commit d09b242

Browse files
committed
initial version
1 parent e5b857c commit d09b242

File tree

2 files changed

+77
-1
lines changed

2 files changed

+77
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ INSERT INTO `DATABASE`.`TABLE` (`COLUMN1`, `COLUMN2`, ...) VALUES (NULL, NULL, N
6969

7070
## Contributing
7171

72-
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.
72+
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.
7373

7474

7575

README.md.bak

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# MySQL data administration in Excel
2+
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+
A new file will be created in the same directory, where Excel file is.
21+
22+
In case 1:
23+
24+
1. open Excel
25+
2. set "file name"
26+
3. set "file extension" to "csv"
27+
4. set "use SQL statement.." to "No"
28+
5. click on "Generate file" button
29+
30+
The file can then be imported in MySQL workbench (*current limitation - for different tables you shall create different files!!*)
31+
32+
In case 2:
33+
34+
1. open Excel
35+
2. set "file name"
36+
3. set "file extension" to "txt"
37+
4. set "use SQL statement.." to "Yes"
38+
5. click on "Generate file" button
39+
40+
With this file - you can run all SQL inserts in PhpMyAdmin, for example.
41+
42+
### Creating worksheets (tables)
43+
44+
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 better managing capabilities.
45+
46+
1. go to "Mysql Workbench"
47+
2. go to diagram view of your table
48+
3. right click on table and use the option called "Copy Insert Template to Clipboard"
49+
4. open Excel document
50+
5. paste the insert template into field "Insert statement"
51+
6. click on "Add Worksheet(Table)" button
52+
53+
> P.S.: A button "Copy Insert Template to Clipboard" always generates data in format:
54+
```
55+
INSERT INTO `DATABASE`.`TABLE` (`COLUMN1`, `COLUMN2`, ...) VALUES (NULL, NULL, NULL, ...);
56+
```
57+
> 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.
58+
59+
## Conventions
60+
61+
- Excel shall always have a "main" worksheet and it shall be first in the list
62+
- Worksheet (non-main) should have the matching name with the table name in order to generate data correctly
63+
- In non-main worksheet - row 1 can have a value: NUMBER. This will force to not-use single quote for the generated value
64+
- 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"
65+
- 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.
66+
- In non-main worksheet - row 4+. These are rows with your data.
67+
- For all data rows where you are not putting "NUMBER" in row 1 - the script will automatically enclose the value in single quote characters
68+
- Is you are using a double quote in your data cell value - it will automatically escape using the \ symbol so " will become \"
69+
70+
## Contributing
71+
72+
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.
73+
74+
75+
76+

0 commit comments

Comments
 (0)