我想写一本有某些信息的书状。 我的表格中有一个栏目是,我想为每个条目节省一个档案。
我如何阅读档案(综合),并用假日插入该档案。 同样,我如何取回,并写回硬车上某些任意地点?
我想写一本有某些信息的书状。 我的表格中有一个栏目是,我想为每个条目节省一个档案。
我如何阅读档案(综合),并用假日插入该档案。 同样,我如何取回,并写回硬车上某些任意地点?
thedata = open( thefile , rb ).read()
sql = "INSERT INTO sometable (theblobcolumn) VALUES (%s)"
cursor.execute(sql, (thedata,))
That code of course works as written only if your table has just the BLOB column and what you want to do is INSERT, but of course you could easily tweak it to add more columns, use UPDATE instead of INSERT, or whatever it is that you exactly need to do.
I m also assuming your file is binary rather than text, etc; again, if my guesses are incorrect it s easy for you to tweak the above code accordingly.
Some kind of SELECT
on cursor.execute
, then some kind of fetching from the cursor, is how you
retrieve BLOB data, exactly like you retrieve any other kind of data.
您可插入并读出行文中与所有其他一栏一样的行文。 从数据库APICS的角度来看,对BLOBs没有任何特殊意义。