@name 执行SQL语句 @param args['path'] 数据库路径 @param args['sql_shell'] SQL语句 @return bool
(self,args)
| 339 | return public.returnMsg(False,'创建失败,error:{}'.format(result)) |
| 340 | |
| 341 | def execute_sql(self,args): |
| 342 | """ |
| 343 | @name 执行SQL语句 |
| 344 | @param args['path'] 数据库路径 |
| 345 | @param args['sql_shell'] SQL语句 |
| 346 | @return bool |
| 347 | """ |
| 348 | |
| 349 | path = args.path |
| 350 | if not os.path.exists(path): |
| 351 | return public.returnMsg(False,'数据库不存在.') |
| 352 | |
| 353 | data = self.get_database_list() |
| 354 | if not path in data: |
| 355 | return public.returnMsg(False,'数据库不存在.') |
| 356 | |
| 357 | sql_shell = args.sql_shell |
| 358 | db = self.get_db_info(path) |
| 359 | if not db: |
| 360 | return public.returnMsg(False,'数据库文件错误.') |
| 361 | sql = db['sql'] |
| 362 | result = sql.execute(sql_shell) |
| 363 | |
| 364 | if result.find('error') != -1: |
| 365 | return public.returnMsg(True,'执行成功,受影响行数{}.'.format(result)) |
| 366 | |
| 367 | return public.returnMsg(False,'执行失败,{}'.format(result)) |
| 368 | |
| 369 | def query_sql(self,args): |
| 370 | """ |
nothing calls this directly
no test coverage detected