如何从像"monkey 2010-07-10 love banana"这样的字符串中提取日期?谢谢!
我正在尝试编写一个简单的Python脚本,将.odt文档插入到SQLite数据库中.这是我到目前为止所做的,但它似乎不起作用:
f=open('Loremipsum.odt', 'rb')
k=f.read()
f.close()
cursor.execute="INSERT INTO notes (note) VALUES ('%s')" %(sqlite.Binary(k))
cursor.close()
conn.close()
Run Code Online (Sandbox Code Playgroud)
我没有收到任何错误消息,但据我所知,记录未插入.我究竟做错了什么?另外,如何将存储的文档提取回来?谢谢!
一个无能的Python新手需要帮助.我混淆了创建一个简单的脚本,将二进制文件插入到SQLite数据库的博客字段中:
import sqlite3
conn = sqlite3.connect('database.db')
cursor = conn.cursor()
input_note = raw_input(_(u'Note: '))
input_type = 'A'
input_file = raw_input(_(u'Enter path to file: '))
with open(input_file, 'rb') as f:
ablob = f.read()
f.close()
cursor.execute("INSERT INTO notes (note, file) VALUES('"+input_note+"', ?)", [buffer(ablob)])
conn.commit()
conn.close()
Run Code Online (Sandbox Code Playgroud)
现在我需要编写一个脚本来抓取特定记录的blob字段的内容,并将二进制blob写入文件.在我的例子中,我使用SQLite数据库来存储.odt文档,所以我想抓取它们并将它们保存为.odt文件.我该怎么做?谢谢!