@name 创建表
(self,args)
| 309 | |
| 310 | |
| 311 | def create_table(self,args): |
| 312 | """ |
| 313 | @name 创建表 |
| 314 | """ |
| 315 | path = args.path |
| 316 | if not os.path.exists(path): |
| 317 | return public.returnMsg(False,'数据库不存在.') |
| 318 | |
| 319 | data = self.get_database_list() |
| 320 | if not path in data: |
| 321 | return public.returnMsg(False,'数据库不存在.') |
| 322 | |
| 323 | table = args.table |
| 324 | sql_shell = args.sql_shell |
| 325 | db = self.get_db_info(path) |
| 326 | if not db: |
| 327 | return public.returnMsg(False,'数据库文件错误.') |
| 328 | |
| 329 | sql = db['sql'] |
| 330 | tables = sql.query('select `name` from sqlite_master where type="table"') |
| 331 | if table in tables: |
| 332 | return public.returnMsg(False,'数据表已存在.') |
| 333 | |
| 334 | result = sql.execute(sql_shell) |
| 335 | tables = sql.query('select `name` from sqlite_master where type="table"') |
| 336 | if table in tables: |
| 337 | return public.returnMsg(True,'创建成功.') |
| 338 | else: |
| 339 | return public.returnMsg(False,'创建失败,error:{}'.format(result)) |
| 340 | |
| 341 | def execute_sql(self,args): |
| 342 | """ |
no test coverage detected