Skip to content

Commit c3127b8

Browse files
committed
adjust code structure
1 parent 3351c61 commit c3127b8

File tree

14 files changed

+215
-180
lines changed

14 files changed

+215
-180
lines changed

.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ root = true
44

55
[*]
66
charset = utf-8
7+
end_of_line = lf
78
insert_final_newline = true
89

910
# Docstrings and comments use max_line_length = 79

.gitignore

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
__pycache__
2-
dist
3-
build
4-
.env
5-
.idea
6-
.vscode
7-
*.pyc
1+
__pycache__
2+
dist
3+
build
4+
.env
5+
.idea
6+
*.pyc

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"python.pythonPath": ".env\\Scripts\\python.exe",
3+
"python.formatting.yapfPath": ".env\\\\Scripts\\\\yapf"
4+
}

DESIGN.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
## 界面设计
2-
1. 读取配置文件,如果用户没有打开过任何的sqlite数据库文件,则“弹窗”要求用户选择sqlite数据库文件,否则打开列表,展示打开过的sqlite数据库文件,让用户选择
3-
2. 用户选择相应的数据库文件后,进入“主界面”,主界面分[左右]两部分显示,左边展示所有的表,右边默认打开执行sql脚本的输入框
1+
## 界面设计
2+
1. 读取配置文件,如果用户没有打开过任何的sqlite数据库文件,则“弹窗”要求用户选择sqlite数据库文件,否则打开列表,展示打开过的sqlite数据库文件,让用户选择
3+
2. 用户选择相应的数据库文件后,进入“主界面”,主界面分[左右]两部分显示,左边展示所有的表,右边默认打开执行sql脚本的输入框

README.md

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
1-
# SQLite client tool
2-
3-
## Dependencies
4-
- wxPython
5-
- pyinstaller
6-
- yapf
7-
8-
## Development
9-
1. Clone this repository
10-
```bash
11-
git clone https://github.com/linychuo/SQLiteClient.git
12-
```
13-
2. You could run **cmd** behind root dir
14-
```bash
15-
Usage cmd [command]
16-
17-
where [command] is one of:
18-
init create new virtual env
19-
active active virtual env
20-
deactive deactive virtual env
21-
prepare install all dependencies
22-
build package exe file
23-
fmt formatting all py files
24-
clean clean
25-
```
1+
# SQLite client tool
2+
3+
## Dependencies
4+
- wxPython
5+
- pyinstaller
6+
- yapf
7+
8+
## Development
9+
1. Please install python3!!!
10+
2. Clone this repository
11+
```bash
12+
git clone https://github.com/linychuo/SQLiteClient.git
13+
```
14+
3. You could run **dev** behind root dir
15+
```bash
16+
Usage dev [command]
17+
18+
where [command] is one of:
19+
init create new virtual env
20+
active active virtual env
21+
deactive deactive virtual env
22+
prepare install all dependencies
23+
build package exe file
24+
fmt formatting all py files
25+
clean clean
26+
```

app.spec

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
# -*- mode: python -*-
2-
3-
block_cipher = None
4-
5-
6-
a = Analysis(['app.py'],
7-
pathex=['D:\\workspace\\SQLiteClient'],
8-
binaries=[],
9-
datas=[],
10-
hiddenimports=[],
11-
hookspath=[],
12-
runtime_hooks=[],
13-
excludes=[],
14-
win_no_prefer_redirects=False,
15-
win_private_assemblies=False,
16-
cipher=block_cipher)
17-
pyz = PYZ(a.pure, a.zipped_data,
18-
cipher=block_cipher)
19-
exe = EXE(pyz,
20-
a.scripts,
21-
exclude_binaries=True,
22-
name='SQLiteClient',
23-
debug=False,
24-
strip=False,
25-
upx=True,
26-
console=False )
27-
coll = COLLECT(exe,
28-
a.binaries,
29-
a.zipfiles,
30-
a.datas,
31-
strip=False,
32-
upx=True,
33-
name='SQLiteClient')
1+
# -*- mode: python -*-
2+
3+
block_cipher = None
4+
5+
6+
a = Analysis(['app.py'],
7+
pathex=['D:\\workspace\\SQLiteClient\\xman'],
8+
binaries=[],
9+
datas=[],
10+
hiddenimports=[],
11+
hookspath=[],
12+
runtime_hooks=[],
13+
excludes=[],
14+
win_no_prefer_redirects=False,
15+
win_private_assemblies=False,
16+
cipher=block_cipher)
17+
pyz = PYZ(a.pure, a.zipped_data,
18+
cipher=block_cipher)
19+
exe = EXE(pyz,
20+
a.scripts,
21+
exclude_binaries=True,
22+
name='SQLiteClient',
23+
debug=False,
24+
strip=False,
25+
upx=True,
26+
console=False )
27+
coll = COLLECT(exe,
28+
a.binaries,
29+
a.zipfiles,
30+
a.datas,
31+
strip=False,
32+
upx=True,
33+
name='SQLiteClient')

cmd.bat renamed to dev.bat

Lines changed: 73 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,73 @@
1-
@echo off
2-
set ACTION=%~1
3-
4-
if "init" == "%ACTION%" (
5-
goto :init
6-
) else if "active" == "%ACTION%" (
7-
goto :activate
8-
) else if "deactive" == "%ACTION%" (
9-
goto :deactivate
10-
) else if "prepare" == "%ACTION%" (
11-
goto :prepare
12-
) else if "build" == "%ACTION%" (
13-
goto :build
14-
) else if "fmt" == "%ACTION%" (
15-
goto :fmt
16-
) else if "clean" == "%ACTION%" (
17-
goto :clean
18-
) else (
19-
goto :usage
20-
)
21-
22-
:init
23-
virtualenv .env
24-
goto :eof
25-
26-
:activate
27-
if not exist "%~dp0.env\Scripts\activate.bat" call:init
28-
call %~dp0.env\Scripts\activate.bat
29-
goto :eof
30-
31-
:deactivate
32-
if exist "%~dp0.env\Scripts\deactivate.bat" (
33-
call %~dp0.env\Scripts\deactivate.bat
34-
)
35-
goto :eof
36-
37-
:prepare
38-
if not exist "%~dp0.env\Scripts\pip.exe" call:activate
39-
call %~dp0.env\Scripts\pip.exe install -r requirements.txt
40-
goto :eof
41-
42-
:build
43-
if not exist "%~dp0.env\Scripts\pyinstaller.exe" call:prepare
44-
call %~dp0.env\Scripts\pyinstaller.exe app.spec
45-
goto :eof
46-
47-
:fmt
48-
if not exist "%~dp0.env\Scripts\yapf.exe" call:prepare
49-
for %%d in (*.py) do (
50-
echo formatting... %%d
51-
call %~dp0.env\Scripts\yapf.exe -i %%d
52-
)
53-
goto :eof
54-
55-
:clean
56-
if exist "%~dp0\build" rmdir/s/q build
57-
if exist "%~dp0\dist" rmdir/s/q dist
58-
goto :eof
59-
60-
:usage
61-
set space_2=
62-
set space_4=
63-
echo.
64-
echo Usage cmd [command]
65-
echo.
66-
echo where [command] is one of:
67-
echo %space_2%init %space_4%create new virtual env
68-
echo %space_2%active %space_4%active virtual env
69-
echo %space_2%deactive %space_4%deactive virtual env
70-
echo %space_2%prepare %space_4%install all dependencies
71-
echo %space_2%build %space_4%package exe file
72-
echo %space_2%fmt %space_4%format all py files
73-
echo %space_2%clean %space_4%clean
1+
@echo off
2+
set ACTION=%~1
3+
4+
if "init" == "%ACTION%" (
5+
goto :init
6+
) else if "active" == "%ACTION%" (
7+
goto :activate
8+
) else if "deactive" == "%ACTION%" (
9+
goto :deactivate
10+
) else if "prepare" == "%ACTION%" (
11+
goto :prepare
12+
) else if "build" == "%ACTION%" (
13+
goto :build
14+
) else if "fmt" == "%ACTION%" (
15+
goto :fmt
16+
) else if "clean" == "%ACTION%" (
17+
goto :clean
18+
) else (
19+
goto :usage
20+
)
21+
22+
:init
23+
python -m venv .env
24+
goto :eof
25+
26+
:activate
27+
if not exist "%~dp0.env\Scripts\activate.bat" call:init
28+
call %~dp0.env\Scripts\activate.bat
29+
goto :eof
30+
31+
:deactivate
32+
if exist "%~dp0.env\Scripts\deactivate.bat" (
33+
call %~dp0.env\Scripts\deactivate.bat
34+
)
35+
goto :eof
36+
37+
:prepare
38+
if not exist "%~dp0.env\Scripts\pip.exe" call:activate
39+
call %~dp0.env\Scripts\pip.exe install -r requirements.txt
40+
goto :eof
41+
42+
:build
43+
if not exist "%~dp0.env\Scripts\pyinstaller.exe" call:prepare
44+
call %~dp0.env\Scripts\pyinstaller.exe app.spec
45+
goto :eof
46+
47+
:fmt
48+
if not exist "%~dp0.env\Scripts\yapf.exe" call:prepare
49+
for %%d in (*.py) do (
50+
echo formatting... %%d
51+
call %~dp0.env\Scripts\yapf.exe -i %%d
52+
)
53+
goto :eof
54+
55+
:clean
56+
if exist "%~dp0\build" rmdir/s/q build
57+
if exist "%~dp0\dist" rmdir/s/q dist
58+
goto :eof
59+
60+
:usage
61+
set space_2=
62+
set space_4=
63+
echo.
64+
echo Usage cmd [command]
65+
echo.
66+
echo where [command] is one of:
67+
echo %space_2%init %space_4%create new virtual env
68+
echo %space_2%active %space_4%active virtual env
69+
echo %space_2%deactive %space_4%deactive virtual env
70+
echo %space_2%prepare %space_4%install all dependencies
71+
echo %space_2%build %space_4%package exe file
72+
echo %space_2%fmt %space_4%format all py files
73+
echo %space_2%clean %space_4%clean

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
wxPython
22
pyinstaller
3+
yapf

app.py renamed to xman/app.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding=utf-8 -*-
21
"""
32
Main application
43
"""

db.py renamed to xman/db.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33

44
class TableMeta:
5-
6-
def __init__(self, idx, column_name, column_type, is_null, default_value, is_pk):
5+
def __init__(self, idx, column_name, column_type, is_null, default_value,
6+
is_pk):
77
self.idx = idx + 1
88
self.column_name = column_name
99
self.column_type = column_type
@@ -22,15 +22,18 @@ def get_object_type(self):
2222
result = []
2323
with sqlite3.connect(self.db_file) as conn:
2424
c = conn.cursor()
25-
for row in c.execute("select type from sqlite_master group by type"):
25+
for row in c.execute(
26+
"select type from sqlite_master group by type"):
2627
result.append(row[0].capitalize())
2728
return result
2829

2930
def get_object_list(self, object_type):
3031
object_list = []
3132
with sqlite3.connect(self.db_file) as conn:
3233
c = conn.cursor()
33-
for _row in c.execute("select * from sqlite_master where type = ?", (object_type,)):
34+
for _row in c.execute("select * from sqlite_master where type = ?",
35+
(object_type, )):
36+
print(_row)
3437
object_list.append(_row[1])
3538
return object_list
3639

@@ -40,5 +43,14 @@ def get_meta_of_table(self, table_name):
4043
cur = conn.cursor()
4144
for row in cur.execute("PRAGMA table_info(%s)" % table_name):
4245
print(row)
43-
meta_data.append(TableMeta(row[0], row[1], row[2], row[3], row[4], row[5]))
46+
meta_data.append(
47+
TableMeta(row[0], row[1], row[2], row[3], row[4], row[5]))
48+
return meta_data
49+
50+
def get_meta_of_index(self, index_name):
51+
meta_data = []
52+
with sqlite3.connect(self.db_file) as conn:
53+
cur = conn.cursor()
54+
for row in cur.execute("PRAGMA index_info(%s)" % index_name):
55+
print(row)
4456
return meta_data

0 commit comments

Comments
 (0)