未定义名称';错误';用Python

未定义名称';错误';用Python,python,Python,我正在尝试使用Python3连接sqlite数据库 代码-- 我收到一个错误--有一个未定义的名为“error” 非常感谢您的帮助。提前感谢。看起来很清楚,名称Error没有定义。我相信您要使用的是sqlite3。错误。是的,错误没有定义。这似乎很简单。你为什么认为它被定义了?不用担心——它发生在我们当中最好的人身上。:-) import sys,os import datetime as dt import sqlite3 from datetime import date,datetime

我正在尝试使用Python3连接sqlite数据库

代码--

我收到一个错误--
有一个未定义的名为“error”


非常感谢您的帮助。提前感谢。

看起来很清楚,名称
Error
没有定义。我相信您要使用的是
sqlite3。错误

是的,
错误
没有定义。这似乎很简单。你为什么认为它被定义了?不用担心——它发生在我们当中最好的人身上。:-)
import sys,os
import datetime as dt
import sqlite3
from datetime import date,datetime

def create_connection(db_file):
    """ create a database connection to the SQLite database
        specified by db_file
    :param db_file: database file
    :return: Connection object or None
    """
    try:
        conn = sqlite3.connect(db_file)
        return conn
    except Error as e:
        print(e)

    return None


def main():
  database = r"C:\Users\prith\Documents\sqlitedb\filedb.db"
# create a database connection
    conn = create_connection(database)

if __name__ == '__main__':
    main()