Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.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 从Django中的请求体读取sqlite_Python_Django_Sqlite - Fatal编程技术网

Python 从Django中的请求体读取sqlite

Python 从Django中的请求体读取sqlite,python,django,sqlite,Python,Django,Sqlite,我想从请求体读取sqlite数据库,而不将其保存到临时文件中 请求已由以下人员发送: curl-X POST-data binary@mydb.sqlite3-H内容类型:application/octet-streamhttp://localhost:8000/upload_sqlite 我的视图功能如下: def上传请求: printrequest.body conn=sqlite3.connectrequest.body 光标=连接光标 cursor.executeSELECT*自表 做点

我想从请求体读取sqlite数据库,而不将其保存到临时文件中

请求已由以下人员发送:

curl-X POST-data binary@mydb.sqlite3-H内容类型:application/octet-streamhttp://localhost:8000/upload_sqlite

我的视图功能如下:

def上传请求: printrequest.body conn=sqlite3.connectrequest.body 光标=连接光标 cursor.executeSELECT*自表 做点什么 光标。关闭 康涅狄格州 返回HttpResponsestatus=200 控制台输出如下:

SQLite格式3\x00\x04\x00\x01\x01\x00@\x00\x00\x00\x00\x18\x00\x00\x00\x00\x0b\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00……' …忽略。。。 上传sqlite中的文件/path/to/views.py,第208行 conn=sqlite3.connectrequest.body ValueError:嵌入的空字节 2019.11.20更新:

当前按临时文件列出的解决方案:

def上传请求: fd,filename=tempfile.mkstemp os.writefd,request.body conn=sqlite3.connectfilename 光标=连接光标 cursor.executeSELECT*自表 做点什么 光标。关闭 康涅狄格州 闭合器 返回HttpResponsestatus=200
有一种方法可以在C中实现,但是Python绑定没有导出必要的API。谢谢@Shawn。这样做的唯一方法似乎是创建一个临时文件,直到Python的sqlite支持序列化/反序列化函数为止……使用