zillow / ctds

Python DB-API 2.0 library for MS SQL Server
MIT License
83 stars 12 forks source link

when I use db.bulk_insert , an error occurd #57

Closed zhaoziming closed 4 years ago

zhaoziming commented 4 years ago

python3: data.c:977: tds_generic_put: Assertion `curcol->column_varint_size' failed. len(data)≈20000,not many

    db = ctds.connect(server=dbinfo['DBaddr'], port=int(dbinfo['DBport']), user=dbinfo['DBusername'], password=dbinfo['DBpw'], database=dbinfo['DBname'])

    data = []
    for index, row in df.iterrows():
        temp = {}
        temp['id'] = None
        temp['city'] = ctds.SqlVarChar(row['city'].encode("utf-16le"))
        temp['month'] = ctds.SqlChar(row['month'].encode("utf-16le"))
        temp['houseid'] = ctds.SqlInt(row['HouseId'])
        temp['projcode'] = ctds.SqlBigInt(row['ProjCode'])
        temp['projname'] = ctds.SqlVarChar(row['ProjName'].encode("utf-16le"))
        temp['district'] = ctds.SqlVarChar(row['District'].encode("utf-16le"))
        temp['comarea'] = ctds.SqlVarChar(row['Comarea'].encode("utf-16le"))
        temp['propertysubtype'] = ctds.SqlVarChar(row['PropertySubType'].encode("utf-16le"))
        temp['room'] = ctds.SqlSmallInt(row['Room'])
        temp['floor'] = ctds.SqlSmallInt(row['FLOOR'])
        temp['totalfloor'] = ctds.SqlSmallInt(row['TotalFloor'])
        temp['forward'] = ctds.SqlVarChar(row['Forward'].encode("utf-16le"))
        temp['buildingarea'] = ctds.SqlDecimal(row['BuildingArea'], 18, 2)
        temp['price'] = ctds.SqlDecimal(row['Price'], 18, 2)
        temp['unitprice'] = ctds.SqlDecimal(row['unitprice'], 18, 2)
        temp['create_time'] = None
        temp['update_time'] = None
        temp['is_del'] = None

        data.append(temp)

    tablename = "baicheng_esf_online_data_%s" % month
    db.bulk_insert(tablename, data)
    db.commit()
joshuahlang commented 4 years ago

Are you using the most recent version of FreeTDS?

joshuahlang commented 4 years ago

Closing due to no response