簡體   English   中英

試圖使用python檢查sqlite數據庫中是否存在用戶名

[英]trying to check if username exists in sqlite database using python

嘗試使用python 3檢查用戶名是否在sqlite中存在

這就是我嘗試過的

    checkUsername = self.c.execute("SELECT username FROM Login WHERE username = ? AND position = ?",
                   (username, manager))

    if checkUsername != 0:
        print("Wrong username and password")
    else:
        print("correct")

如果使用sqlite3模塊,cursor.execute不會返回結果。 您需要使用cursor.fetchone()或cursor.fetchall()來獲取結果,這些結果以元組或元組列表的形式返回。

有關更多詳細信息,請參見此處的文檔。

暫無
暫無

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

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