Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/350.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中调用数据库?获取500内部服务器错误_Python_Database_Sqlite_Cursor - Fatal编程技术网

Python 如何在sqlite3中调用数据库?获取500内部服务器错误

Python 如何在sqlite3中调用数据库?获取500内部服务器错误,python,database,sqlite,cursor,Python,Database,Sqlite,Cursor,我的服务器中有一个名为ex的数据库 因此,在我的python脚本(其中导入了sqlite3)中,我将尝试插入值 try: # Initial setup runs one time connect = sqlite3.connect('ex') cursor = connect.cursor() except Exception as e: error_string = e # Insert query into the cursor cursor.exec

我的服务器中有一个名为
ex
的数据库

因此,在我的python脚本(其中导入了sqlite3)中,我将尝试插入值

try:
    # Initial setup runs one time
    connect = sqlite3.connect('ex')
    cursor = connect.cursor()
except Exception as e:
    error_string = e


# Insert query into the cursor 
cursor.execute("INSERT INTO student_urls (user_name,assignment,url,created_at) \
    values(?,?,?,date('now'))" ,(user_name,assignment, url))

但是cursor.execute行给了我一些问题。。。特别是我得到一个500内部服务器错误。有什么想法吗?

指定SQL数据库的完整路径,如
sqlite3.connect('/var/www/ex.db')
。此外,请确保应用程序具有足够的读/写权限。在服务器上托管Flask应用程序时,我遇到了相同的问题,并且必须使用完整路径和
chmod-R
my app目录

请发布错误。'内部服务器错误服务器遇到内部错误或配置错误,无法完成您的请求。请与服务器管理员联系,root@localhost并告知他们错误发生的时间,以及您可能采取的任何可能导致错误的措施。有关此错误的详细信息,请参阅服务器错误日志。'抱歉,请快速提问。我是否正确地编写了connect=sqlite3.connect(“ex”)?只是“ex”?我不认为这与python有关。您应该写入整个数据库名称,
ex
ex.db
是不同的。也许你没有局长的权力,这要看情况而定。您应该调用文件的名称。如果没有这样的文件。sqlite3将为您创建一个。