我有一个包含来自MySQL的表和数据的导出SQL文件,我想将其导入Sqlite 3 DB.
最好的方法是什么?
只通过sqlite3工具导入文件不起作用.
我正在使用Django构建一个Web应用程序.我通过Ajax(jQuery v1.8.3)在Javascript中有一堆API调用.
它们中的大多数都可以工作,但是特定的一个会导致状态为0的返回对象,并且此消息为statusText:
[Exception... "'JavaScript component does not have a method named: "available"' when calling method: [nsIInputStream::available]" nsresult: "0x80570030 (NS_ERROR_XPC_JSOBJECT_HAS_NO_FUNCTION_NAMED)" location: "JS frame :: http://127.0.0.1:8000/media/js/jquery.js :: .send :: line 8434" data: no]
jQuery中的对应行是 xhr.send( ( s.hasContent && s.data ) || null );
但是,这只发生在Firefox中.Chrome工作正常.同样,其他请求也可以.唯一让这个与众不同的是DELETE http方法.
请求如下(Chrome中显示的HTTP网络数据 - Firebug在Firefox中没有显示任何内容):
Request URL: http://127.0.0.1:8000/api/reservation/13/
Request Method: DELETE
Status Code: 400 BAD REQUEST (This is expected)
Request Headers
Accept: application/json, text/javascript, */*; q=0.01
Content-Length: 15
Content-Type: application/json
Origin: http://127.0.0.1:8000
Referer: http://127.0.0.1:8000/reservation/
X-Requested-With: XMLHttpRequest
Request Payload …Run Code Online (Sandbox Code Playgroud) tasks = list(self.collection.find().sort('_id',pymongo.DESCENDING).limit(1000))
Run Code Online (Sandbox Code Playgroud)
当我使用 pymongo 解决程序时遇到了麻烦。
文件“D:\Python27\lib\site-packages\pymongo-3.2.1-py2.7-win-amd64.egg\pymongo\cursor.py”,第 1097 行,在下一个文件“D:\Python27\lib\”中site-packages\pymongo-3.2.1-py2.7-win-amd64.egg\pymongo\cursor.py”,第 1039 行,在 _refresh 文件“D:\Python27\lib\site-packages\pymongo-3.2.1 -py2.7-win-amd64.egg\pymongo\cursor.py”,第 903 行,在 __send_message 文件“D:\Python27\lib\site-packages\pymongo-3.2.1-py2.7-win-amd64”中。 egg\pymongo\helpers.py”,第 133 行,在 _unpack_response bson.errors.InvalidBSON:'utf8' 编解码器无法解码位置 25 的字节 0xa1:无效的起始字节
tasks =self.collection.find().sort('_id',pymongo.DESCENDING).limit(1000)
for task in tasks: #If i use this way,it will also touch this problem
task = self.collection.find_one()#It would do so,too
Run Code Online (Sandbox Code Playgroud)
我进入pymongo找出原因。我发现问题可能是由以下代码引起的
result = {"cursor_id": struct.unpack("<q", response[4:12])[0],
"starting_from": struct.unpack("<i", response[12:16])[0],
"number_returned": struct.unpack("<i", response[16:20])[0],
"data": bson.decode_all(response[20:], codec_options)}
Run Code Online (Sandbox Code Playgroud)
在 pymongo helper.py 133 行中的 bson.decode_all 它显示了由关于 'oid' 的解码失败导致的问题?'oid' 是 mongo 中的 _id。然后我复制文档并使用新的 _id 创建相同的文档,然后我成功拿到了文件。
我如何解决“任务中的任务:”样式的问题。 …