Python RPA 数据库篇 8 - oracle 篇 1 - 查询数据

Python RPA 数据库篇 8 - oracle 篇 1 - 查询数据

oracle 篇 1 - 查询数据

代码

#!/usr/bin/env Python3
# -*- coding: utf-8 -*-
# @Software: PyCharm
# @virtualenv:workon
# @contact: contact information
# @Desc:Code descripton
__author__ = '未昔/AngelFate'
__date__ = '2019/8/29 22:05'
import cx_Oracle

#连接数据库
db = cx_Oracle.connect('root/123456@localhost/novel')
cursor = db.cursor()

cursor.execute ("SELECT * FROM novel")

rows = cursor.fetchall() #得到所有数据集

for row in rows:
  print("%d, %s, %s, %s" % (row[0], row[1], row[2], row[3]))


cursor.close ()
db.close()