m0_46685009
2022-04-01 09:58
采纳率: 52.5%
浏览 34
已结题

python数据表插入

def insert_Table_basics(data_list):
    conn = psycopg2.connect(database="aigdb", user="wlaigadmin", password="wlaigadmin", host="localhost", port="5432")
    cursor=conn.cursor()
    for route in data_list:

        route_str = "insert into basics(ip,production_line_number,username,password) values('"+str(route[0])+"','"+route[1]+"','"+route[2]+"','"+route[3]+"'"+")"
              
        cursor.execute(route_str)

    conn.commit()
    conn.close()
    

因为route[1]建表格式不是str 插入时直接+会说str和其他格式不能相加,这个插入函数怎么改

3条回答 默认 最新

相关推荐 更多相似问题