forked from ryjfgjl/DiLuConverter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
78 lines (73 loc) · 2.81 KB
/
main.py
File metadata and controls
78 lines (73 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#######################################################################################################################
# Tool Name: ExcelToDatabase
# Version: V4.3
# Bref: A tool which can batch import excel files into mysql/oracle database.
# Feature: Automation, One-Click, High Speed, Automatic Correct Error
# Tested Environment: Windows 7+, MySQL 5.6+/Oracle 11g+, Excel 1997+(xls,xlsx,csv)
# Author: ryjfgjl
# Help Email: 2577154121@qq.com
#######################################################################################################################
# Version
Version = "4.3"
import PySimpleGUI as sg
import traceback
import sys
import pyperclip
# import configuration file
from common.handleconfig import HandleConfig
from gui.gui import Gui
sg.ChangeLookAndFeel('dark')
HandleConfig = HandleConfig()
Gui = Gui()
# format exception output
def exception_format():
return "".join(traceback.format_exception(
sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2],limit=1
))
# GO
default_values = HandleConfig.get_defaults()
window = sg.Window('ExcelToDatabase {0}'.format(Version), Gui.generate_layout(), location=(700, 100))
# keep running
while True:
try:
event, values = window.read()
if values != None:
values['dbtype'] = default_values['dbtype']
# start
if event == "Start" or event == 'Start0' or event == "开始" or event == '开始0':
from events.importer import Importer
Importer = Importer(values)
Importer.main()
# change database type
elif event == 'MySQL' or event == 'Oracle':
from events.setting import Setting
Setting = Setting()
Setting.db_type(event)
window.close()
HandleConfig.save_defaults(values)
window = sg.Window('ExcelToDatabase {0}'.format(Version), Gui.generate_layout(), location=(700, 100))
window.Finalize()
# change language
elif event == 'English' or event == '中文':
from events.setting import Setting
Setting = Setting()
Setting.switch_langage(event)
window.close()
HandleConfig.save_defaults(values)
window = sg.Window('ExcelToDatabase {0}'.format(Version), Gui.generate_layout(), location=(700, 100))
window.Finalize()
elif event == "联系方式":
from events.setting import Setting
Setting = Setting()
msg = Setting.help()
sg.Popup(msg, title='Help')
pyperclip.copy(msg)
elif event == sg.WIN_CLOSED:
break
except:
# throw error
sg.PopupError(exception_format())
finally:
if event != sg.WIN_CLOSED:
HandleConfig.save_defaults(values)
default_values = HandleConfig.get_defaults()