亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

我有一張用戶表。我想編寫一個使用 id 獲取數據的 API。我不斷收到以下錯誤。請注意,數據庫已滿

我有一張用戶表。我想編寫一個使用 id 獲取數據的 API。我不斷收到以下錯誤。請注意,數據庫已滿

Go
慕森王 2023-06-26 15:31:33
我有一張用戶表。我想編寫一個使用 id 獲取數據的 API。我不斷收到以下錯誤。請注意,數據庫已經滿了。我想創建一個 get api,在其中傳遞 id 并獲取該行作為結果。我嘗試了一些方法,但我不斷收到此錯誤。數據庫架構-deadpool=# \d user_data                                           Table "public.user_data"       Column       |           Type           | Collation | Nullable |                Default--------------------+--------------------------+-----------+----------+--------------------------------------- id                 | integer                  |           | not null | nextval('user_data_id_seq'::regclass) created_at         | timestamp with time zone |           |          | updated_at         | timestamp with time zone |           |          | deleted_at         | timestamp with time zone |           |          | name               | text                     |           |          | age                | text                     |           |          | gender             | text                     |           |          | party_code         | text                     |           |          | criminal_cases     | text                     |           |          | number_of_cases    | text                     |           |          | serious_ipc_counts | text                     |           |          | ipc_details        | text                     |           |          | education_level    | text                     |           |          | movable_assets     | text                     |           |          | immovable_assets   | text                     |           |          | total_assets       | text                     |           |          | total_liabilities  | text                     |           |          | pan_given          | text                     |           |          | election           | text                     |           |          | constituency       | text                     |           |          |Indexes:    "user_data_pkey" PRIMARY KEY, btree (id)    "idx_user_data_deleted_at" btree (deleted_at)
查看完整描述

1 回答

?
人到中年有點甜

TA貢獻1895條經驗 獲得超7個贊

您沒有設置包級dbvar,因為您使用:=.


如果出現錯誤,請退出mainfunc,這樣您就不會繼續使用 nil db。


var db *gorm.DB


func main() {

    var err error

    db, err = gorm.Open()

    if err != nil {

        log.Fatalf("unable to connect to database: %s", err.Error())

    }

}


查看完整回答
反對 回復 2023-06-26
  • 1 回答
  • 0 關注
  • 140 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號