簡體   English   中英

Python-插入數據時發生錯誤(TypeError:“ int64”類型的對象不可JSON序列化)

[英]Python - Error when inserting data (TypeError: Object of type 'int64' is not JSON serializable)

我試圖將一些記錄從我的數據框插入到Salesforce,但出現錯誤

TypeError: Object of type 'int64' is not JSON serializable

下面給出的是我正在使用的代碼:

if len(acct) > 0:
    list = []
    for i in range(len(acct)):
        update = {'Id': acct['Id'].iloc[i],
              'name': acct['user_count'].iloc[i]}

        list.append(update)
    sf_data_cursor.bulk.Account.update(list)

下面給出的是列的數據類型:

Column: user_count is of type int64

任何人都可以幫助找到我要去的地方。 謝謝。

更新:

插入之前的數據框視圖:

Id, Name, user_count
1, ABC, 10
2, XYZ, 13

此處的字段映射不正確。 名稱字段輸入不正確。

update = {'Id': acct['Id'].iloc[i], 'name': acct['user_count'].iloc[i]}

請嘗試以下代碼:

if len(acct) > 0:
    list = []
    for i in range(len(acct)):
        update = {'Id': acct['Id'].iloc[i],
              'name': acct['Name'].iloc[i]}

        list.append(update)
    sf_data_cursor.bulk.Account.update(list)

讓我知道這是否解決了您的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM