88@email: boris_liu@foxmail.com
99"""
1010
11- import sys
1211import time
1312
13+ import pyperclip
14+
1415import feapder .setting as setting
1516import feapder .utils .tools as tools
1617from feapder .db .mysqldb import MysqlDB
@@ -62,18 +63,15 @@ def get_data(self):
6263 ---------
6364 @result:
6465 """
65- data = ""
66- while True :
67- line = sys .stdin .readline ().strip ()
68- if not line :
69- break
70- data += line
66+ input ("请复制json格式数据, 复制后按任意键读取剪切板内容\n " )
7167
72- return tools .get_json (data )
68+ text = pyperclip .paste ()
69+ print (text + "\n " )
70+
71+ return tools .get_json (text )
7372
7473 def create (self , table_name ):
7574 # 输入表字段
76- print ('请输入表数据 json格式 如 {"name":"张三"}\n 等待输入:\n ' )
7775 data = self .get_data ()
7876
7977 if not isinstance (data , dict ):
@@ -98,17 +96,21 @@ def create(self, table_name):
9896
9997 comment = input ("%s : %s -> comment:" % (key , key_type ))
10098
101- other_key += "`{key}` {key_type} COMMENT '{comment}',\n " .format (
102- key = key , key_type = key_type , comment = comment
99+ other_key += (
100+ "`{key}` {key_type} COMMENT '{comment}',\n " .format (
101+ key = key , key_type = key_type , comment = comment
102+ )
103103 )
104104
105105 print ("\n " )
106106
107107 while True :
108108 is_need_batch_date = input ("是否添加batch_date 字段 (y/n):" )
109109 if is_need_batch_date == "y" :
110- other_key += "`{key}` {key_type} COMMENT '{comment}',\n " .format (
111- key = "batch_date" , key_type = "date" , comment = "批次时间"
110+ other_key += (
111+ "`{key}` {key_type} COMMENT '{comment}',\n " .format (
112+ key = "batch_date" , key_type = "date" , comment = "批次时间"
113+ )
112114 )
113115 break
114116 elif is_need_batch_date == "n" :
@@ -132,4 +134,5 @@ def create(self, table_name):
132134 )
133135 print (sql )
134136 self ._db .execute (sql )
135- print ("\n %s 创建成功" % table_name )
137+ print ("\n %s 创建成功" % table_name )
138+ print ("注意手动检查下字段类型,确保无误!!!" )
0 commit comments