diff --git a/dataloader/README.md b/dataloader/README.md new file mode 100644 index 0000000..8bc15ad --- /dev/null +++ b/dataloader/README.md @@ -0,0 +1,44 @@ +# dataloader +a tool to load data into database from excel file + +## Dependents +* [Gadget](https://github.com/yumoqing/gadget) + +You should have a gadget run environment installed before, the dataloader +uses gadget conf/config.json file to read the database configuation. + +## Usage +change the current folder to gadget running folder(it contains a "conf" folder which config.json file in it), then +``` +datalaoder excel_data_file +``` + +## Excel file format + +### Specifies the target database +use a datasheet to set the sheet name preffix and subffix with '__', examples: +"__testdb__" stand for "testdb", "__mydatabase__" stand for "mydatabase", + +### Specifies the target table +the table name will use to insert data can be specifies by set the sheet name as the table name + +### Specifies the field name +dataloader can inserts data to a table not necesary provide all the fields data, the table's nullable fields can be ignore. + +first row in the sheet is use to specify the fields with data, each cell for one field, value of the cell should be fill in the table's field name. + +### Specifies the data +Data start from second row in the sheet, each row for one records + +## Examples +there is a kboss database in databases, and the kboss database have two tabel named by 'appcodes' and 'appcodes_kv' + +* Specify database +![specify database](./database.png) + +* Specify table appcodes +![specify appcodes table](./table1.png) + +* Specify table appcodes_kv +![specify table appcodes_kv](./table1.png) + diff --git a/dataloader/database.png b/dataloader/database.png new file mode 100644 index 0000000..519002b Binary files /dev/null and b/dataloader/database.png differ diff --git a/dataloader/table1.png b/dataloader/table1.png new file mode 100644 index 0000000..264e898 Binary files /dev/null and b/dataloader/table1.png differ diff --git a/dataloader/table2.png b/dataloader/table2.png new file mode 100644 index 0000000..9e5b365 Binary files /dev/null and b/dataloader/table2.png differ diff --git a/dataloader/ubuntu/build.sh b/dataloader/ubuntu/build.sh new file mode 100755 index 0000000..c3cf2d9 --- /dev/null +++ b/dataloader/ubuntu/build.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +pyinstaller -y --clean dataloader.spec +echo "build success, please find the target in dist folder" diff --git a/dataloader/ubuntu/dataloader.spec b/dataloader/ubuntu/dataloader.spec new file mode 100644 index 0000000..4b93de1 --- /dev/null +++ b/dataloader/ubuntu/dataloader.spec @@ -0,0 +1,47 @@ +# -*- mode: python ; coding: utf-8 -*- + + +block_cipher = None + + +a = Analysis( + ['../dataloader.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=[ + "aiopg", + "aiomysql" + ], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False, +) +pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name='dataloader', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +) diff --git a/dataloader/windows/build.bat b/dataloader/windows/build.bat new file mode 100755 index 0000000..7288082 --- /dev/null +++ b/dataloader/windows/build.bat @@ -0,0 +1,2 @@ +pyinstaller -y --clean dataloader.spec +echo "build success, please find the target in dist folder" diff --git a/dataloader/windows/dataloader.spec b/dataloader/windows/dataloader.spec new file mode 100644 index 0000000..4b93de1 --- /dev/null +++ b/dataloader/windows/dataloader.spec @@ -0,0 +1,47 @@ +# -*- mode: python ; coding: utf-8 -*- + + +block_cipher = None + + +a = Analysis( + ['../dataloader.py'], + pathex=[], + binaries=[], + datas=[], + hiddenimports=[ + "aiopg", + "aiomysql" + ], + hookspath=[], + hooksconfig={}, + runtime_hooks=[], + excludes=[], + win_no_prefer_redirects=False, + win_private_assemblies=False, + cipher=block_cipher, + noarchive=False, +) +pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) + +exe = EXE( + pyz, + a.scripts, + a.binaries, + a.zipfiles, + a.datas, + [], + name='dataloader', + debug=False, + bootloader_ignore_signals=False, + strip=False, + upx=True, + upx_exclude=[], + runtime_tmpdir=None, + console=True, + disable_windowed_traceback=False, + argv_emulation=False, + target_arch=None, + codesign_identity=None, + entitlements_file=None, +)