Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python sqlite3.0错误:接近“0”)&引用;:语法错误_Python_Sqlite - Fatal编程技术网

Python sqlite3.0错误:接近“0”)&引用;:语法错误

Python sqlite3.0错误:接近“0”)&引用;:语法错误,python,sqlite,Python,Sqlite,我正在尝试运行此代码,但出现以下错误 def staff_database(db_name,table_name,sql_1,admin): with sqlite3.connect('BehaviourManagement.db') as db:#connects this funtion to the database file cursor = db.cursor()#used to naviage around the database curso

我正在尝试运行此代码,但出现以下错误

def staff_database(db_name,table_name,sql_1,admin):
    with sqlite3.connect('BehaviourManagement.db') as db:#connects this funtion to the database file
        cursor = db.cursor()#used to naviage around the database
        cursor.execute("select name from sqlite_master where name=?",(table_name,))#checks database for this table
        result = cursor.fetchall()#gets the results
        if len(result) != 1:#runs if statement if table present in the database
            cursor.execute(sql_1)#runs the sql statement
            db.commit()#ensures changes made to the database are saved
            cursor.execute(insert_to_login ,admin)
            db.commit()

sql_1 = """CREATE TABLE Login(
        ID INTEGER PRIMARY KEY autoincrement,
        username text, 
        password text,
        );"""
回溯(最近一次呼叫最后一次):
文件“M:\computer science a2\comp 3\login.py”,第151行,在
staff_数据库(db_name、table_name、sql_1、admin)运行该函数
staff_数据库中的文件“M:\computer science a2\comp 3\login.py”,第62行
cursor.execute(sql#1)运行sql语句
sqlite3.error:near“:语法错误

如果有人能帮忙,我将不胜感激。

删除“密码文本”之后的最后一个“,”。逗号表示后面有另一个字段。

Fix
sql\u 1

Traceback (most recent call last):
  File "M:\computer science a2\comp 3\login.py", line 151, in <module>
    staff_database(db_name, table_name,sql_1,admin)#runs the function
  File "M:\computer science a2\comp 3\login.py", line 62, in staff_database
    cursor.execute(sql_1)#runs the sql statement
sqlite3.OperationalError: near ")": syntax error

删除
密码文本之后

删除,在密码文本之后。。。
sql_1 = """CREATE TABLE Login(
        ID INTEGER PRIMARY KEY autoincrement,
        username text, 
        password text
        );"""