我正在尝试通过Python连接到Oracle并尝试执行一些DDL& DML语句。请帮助它如何完成
答案 0 :(得分:0)
一个简单的查询
import cx_Oracle
con = cx_Oracle.connect('pythonhol/welcome@127.0.0.1/orcl')
cur = con.cursor()
cur.execute('select * from departments order by department_id')
for result in cur:
print result
cur.close()
con.close()
答案 1 :(得分:0)
您可以这样做:
import cx_Oracle
connection = cx_Oracle.connect("username", "password", "ip of your server"/"database name")
cursor = connection.cursor()
cursor.execute("select * from table_name")
for row in cursor:
print(row)
connection.close()