Some GUI changes
This commit is contained in:
68
dm.py
68
dm.py
@@ -1,34 +1,48 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import sys, json, sqlite3
|
||||
import json
|
||||
|
||||
table_list = open("tables.json", "r")
|
||||
data = json.load(table_list)
|
||||
def createTables(tbl_list):
|
||||
i = 0
|
||||
tbl_names_list = []
|
||||
while i < len(tbl_list):
|
||||
tbl_descr = tbl_list[i]["tableDescription"]
|
||||
tbl_name = tbl_list[i]["tableName"]
|
||||
field_list = tbl_list[i]["fieldList"][i].keys()
|
||||
|
||||
tbl_list = data["tables"]
|
||||
print(len(tbl_list))
|
||||
i = 0
|
||||
while i < len(tbl_list):
|
||||
tbl_descr = data["tables"][i]["tableDescription"]
|
||||
tbl_name = data["tables"][i]["tableName"]
|
||||
field_list = data["tables"][i]["fieldList"][i].keys()
|
||||
tbl_names_list.append(tbl_name)
|
||||
|
||||
x = 0
|
||||
# список всех полей таблицы
|
||||
qwery_create = "CREATE TABLE " + tbl_name + " ("
|
||||
qwery_select = "SELECT * FROM "
|
||||
index = ""
|
||||
while x < len(data["tables"][i]["fieldList"]):
|
||||
if data["tables"][i]["fieldList"][x]["autoIncrement"] == "yes":
|
||||
auto_increment = " AUTOINCREMENT, "
|
||||
else:
|
||||
auto_increment = ", "
|
||||
qwery_create = qwery_create + data["tables"][i]["fieldList"][x]["fName"] + " " + data["tables"][i]["fieldList"][x]["fType"] + auto_increment
|
||||
x = 0
|
||||
# список всех полей таблицы
|
||||
qwery_create = "CREATE TABLE " + tbl_name + " ("
|
||||
qwery_select = "SELECT * FROM "
|
||||
index = ""
|
||||
while x < len(tbl_list[i]["fieldList"]):
|
||||
if tbl_list[i]["fieldList"][x]["autoIncrement"] == "yes":
|
||||
auto_increment = " AUTO_INCREMENT, "
|
||||
else:
|
||||
auto_increment = ", "
|
||||
qwery_create = qwery_create + tbl_list[i]["fieldList"][x]["fName"] + " " + \
|
||||
tbl_list[i]["fieldList"][x]["fType"] + auto_increment
|
||||
|
||||
if data["tables"][i]["fieldList"][x]["index"] == "PRIMARY KEY":
|
||||
index = "PRIMARY KEY(" + data["tables"][i]["fieldList"][x]["fName"] + ")"
|
||||
x = x+1
|
||||
qwery_create = qwery_create + index + ");"
|
||||
if tbl_list[i]["fieldList"][x]["index"] == "PRIMARY KEY":
|
||||
index = "PRIMARY KEY(" + tbl_list[i]["fieldList"][x]["fName"] + ")"
|
||||
x = x + 1
|
||||
qwery_create = qwery_create + index + ");"
|
||||
|
||||
print(qwery_create)
|
||||
#print(qwery_create)
|
||||
i = i + 1
|
||||
return tbl_names_list
|
||||
|
||||
i = i+1
|
||||
def initDBstructure():
|
||||
table_list = open("tables.json", "r", encoding="utf-8")
|
||||
data = json.load(table_list, encoding="utf-8")
|
||||
tbl_list = data["tables"]
|
||||
tbl_names_list = createTables(tbl_list)
|
||||
return tbl_names_list
|
||||
|
||||
def selectData(table_name):
|
||||
# получаем данные из таблицы
|
||||
data_list = ("1","2","3","4","5")
|
||||
return table_name
|
||||
|
||||
initDBstructure()
|
Reference in New Issue
Block a user