oracle_ cursor.executemany

def replace_into1(table_name, table_data):
    table_data = Hr_Kpi.reset_index(drop=True)
    columns = [x for x in list(table_data.columns)]
    cursor=conn.cursor()
    # print(list(table_data.columns))
    # print(len(table_data))
    # table_data.loc[2, ‘SFA终端编号‘]
    # 非空的列名

    x_colnames = [k for k in columns ]
    list1=[ ]
    for j in range(1,len(columns)+1):
        list1.append(":"+str(j))
    #     # 拼接值
#     sql_values = "‘,‘".join(x_value)
    #     # 拼接列名
    sql_colnames = ",".join(x_colnames)
    sql_list1= ",".join(list1)
    #     # 生成插入sql
    insert_sql = ‘insert into %s (%s) values(%s)‘ % (table_name, sql_colnames, sql_list1 )
    print(insert_sql)
    args= list(map(tuple,table_data.astype("str").values))
    cursor.prepare(insert_sql)
    cursor.executemany(None, args) 
    conn.commit()
# replace_into1(‘test‘,Hr_Kpi)

  

oracle_ cursor.executemany

上一篇:Modern计算器—提前体验Windows10的计算器


下一篇:MySQL5.7.x二进制安装