制定完了基础逻辑框架,下一步就是完善基本逻辑
This commit is contained in:
4
.gitignore
vendored
Normal file
4
.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
**/__pycache__
|
||||||
|
**/*.db
|
||||||
|
**/*.sql
|
||||||
|
db/*
|
||||||
0
linux/main.py
Normal file
0
linux/main.py
Normal file
6
packages/python_tcp_to_sqlite.py
Normal file
6
packages/python_tcp_to_sqlite.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import os, sys
|
||||||
|
|
||||||
|
def select_sqlite_dir():
|
||||||
|
print("请选择你的sqlite数据库保存路径", "(默认存储路径为.\\tts\\sqlite\\db)")
|
||||||
|
sqlite_dir = input()
|
||||||
|
print(f"{sqlite_dir}")
|
||||||
3
windows/command/help.py
Normal file
3
windows/command/help.py
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
print("dir", "{:8}选择你需要存放数据库的位置".format(" "))
|
||||||
|
print("list", "{:7}查看你需要存放数据库的位置".format(" "))
|
||||||
|
print("init", "{:7}初始化数据库配置".format(" "))
|
||||||
17
windows/command/init.py
Normal file
17
windows/command/init.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
# 初始化命令脚本
|
||||||
|
import sqlite3
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
# 初始化生成路径
|
||||||
|
# 确定当前路径
|
||||||
|
dir_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
# 确定sqlite数据库初始位置
|
||||||
|
db_path = os.path.dirname(os.path.dirname(dir_path))
|
||||||
|
|
||||||
|
# 建立初始化db文件夹存放数据库
|
||||||
|
os.mkdir(f'{db_path}\\db')
|
||||||
|
|
||||||
|
print(db_path)
|
||||||
|
# 建立sqlite数据库
|
||||||
|
conn = sqlite3.connect(f'{db_path}\\db\\admin.db')
|
||||||
10
windows/command/select_sqlite_dir.py
Normal file
10
windows/command/select_sqlite_dir.py
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
# 导入当前目录下的packages包到环境变量
|
||||||
|
# 获取当前位置绝对路径
|
||||||
|
dir_path = (os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
sys.path.append(os.path.join(dir_path, '../../'))
|
||||||
|
from packages import python_tcp_to_sqlite as tts
|
||||||
|
|
||||||
|
# 选择你需要存放数据库的位置
|
||||||
|
tts.select_sqlite_dir()
|
||||||
27
windows/main.py
Normal file
27
windows/main.py
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# 调用py脚本的主程序
|
||||||
|
# 引入库
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
|
||||||
|
# 设定
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
command = sys.argv[1]
|
||||||
|
|
||||||
|
if command == "help":
|
||||||
|
subprocess.run("python.exe .\\command\\help.py", shell=True)
|
||||||
|
|
||||||
|
elif command == "dir":
|
||||||
|
subprocess.run("python.exe .\\command\\select_sqlite_dir.py", shell=True)
|
||||||
|
|
||||||
|
elif command == "list":
|
||||||
|
subprocess.run("dir", shell=True)
|
||||||
|
|
||||||
|
elif command == "init":
|
||||||
|
subprocess.run("python.exe .\\command\\init.py", shell=True)
|
||||||
|
|
||||||
|
else:
|
||||||
|
print(f"未知的命令: {command}")
|
||||||
|
else:
|
||||||
|
print("tcp_to_sqlite", "v0.01")
|
||||||
|
print("输入 help ", "可以查看支持命令")
|
||||||
Reference in New Issue
Block a user