加载中…
  
博文
标签:

字段

记录

读取

对象

游标

blob

it

分类: python

1、字段的插入

conn = cx_Oracle.connect('testmgr','testmgr','cmsz-yfdev:1521/yfdev')

#获取操作游标  

cursor = conn.cursor() 

binary_var = cursor.var(cx_Oracle.BLOB) #创建blob对象

sys.stdin = open(f_path,'rb')

try:

  binary_data = sys.stdin.read( )

finally:

  sys.stdin.close( )

binary_var.setvalue(0, binary_data) #给blob对象赋值

#path_len=len(f_path)

#add文件,则为1,删除为0

operation=1    #是否为文件,文件为1,文件夹为0

type=1

cursor.execute('INSERT INTO IN_lobs(b,path,oper,type) VALUES(:ba,:pp,:oo,:tt)',ba=binary_var,pp=f_path,oo=operation,tt=type)

2、字段的读取

cursor.execute('SELECT count(*) from (SELECT b,path FROM IN_LOBS where oper=1 and type=1) t')

numrows = cursor.fetchone()  #一次取单条记录,查询符合条件的所有的记录数

cursor.execute('SELECT b,path FROM  IN_LOBS where oper=1 and type=1')

 

  

新浪BLOG意见反馈留言板 欢迎批评指正

新浪简介 | About Sina | 广告服务 | 联系我们 | 招聘信息 | 网站律师 | SINA English | 产品答疑

新浪公司 版权所有