import cx_Oracle
ora=cx_Oracle.connect('molly/123456@localhost:1521/orcl')
cur=ora.cursor()
result=cur.execute("select count(1) from user_tables where table_name='python_txt_oracel'")
rf=result.fetchall()
r=rf[0][0]
if r>0:
cur.execute('drop table python_txt_oracel')
crete_pto="""
create table python_txt_oracel(
pto_id int,
pto_name varchar2(50),
pto_age number
)
"""
#cur.execute(crete_pto)
url=r'C:\Users\Administrator.BF-20211122MHLA\Desktop\Super Money\oracle\8月3日- 大数据的分层理论\python_txt_oracel.txt'
f=open(url,'r')
pto=f.readlines()
for i in pto:
a=i.replace('\n','')
pto_list=a.split(',')
pto_id=pto_list[0]
pto_name=pto_list[1]
pto_age=pto_list[2]
cur.execute(f"insert into python_txt_oracel values({pto_id},'{pto_name}',{pto_age})")
ora.commit()
f.close()
在爬虫软件中写程序,读取txt文件的内容到pl sql 中
最新推荐文章于 2023-06-25 10:04:48 发布