cupleo
def execute_sql_file(sql_path):
    conn_alg,cur_alg = conn_mysql("mysql_algorithm",11433)
    with open(sql_path,\'r+\') as f:
        # every sql job last line marked;
        sql_list = f.read().split(\';\')[:-1]  
        sql_list = [x.replace(\'\n\', \' \') if \'\n\' in x else x for x in sql_list]
    for sql_item  in sql_list:
        print (sql_item)
        try:
            effect_row = cur_alg.execute(sql_item)
            conn_alg.commit()
            print(\'effect rows is {}\'.format(effect_row))
        except Exception as e:
            print(e)

 

分类:

技术点:

相关文章:

  • 2021-10-29
  • 2021-07-25
  • 2021-09-14
  • 2021-10-16
  • 2021-08-15
  • 2021-10-15
  • 2021-11-28
  • 2021-12-18
猜你喜欢
  • 2021-12-28
  • 2021-09-07
  • 2022-01-19
  • 2022-12-23
  • 2022-12-23
  • 2021-11-11
  • 2021-12-05
相关资源
相似解决方案