【发布时间】:2019-11-09 11:22:03
【问题描述】:
大家好,我有这个 sql 文件:
Student.sql
Select * from student where age > 18;
Delet student_ name , studen_id if age > 18 ;
Commit;
使用 cx_oracle pip 任何帮助
【问题讨论】:
-
您不能直接在 Python 解释器中执行 SQL 代码。 Python 解释器不是 SQL 引擎。您需要将其包装起来(通常以字符串形式),然后将该字符串发送到 SQL 引擎以执行。有一些图书馆可以做到这一点,比如
cx_Oracle。 -
我知道这一点,但使用 cx_oracle 我可以找到 .sql 并执行它
-
不确定你在问什么,因为你的问题似乎是“在 python 中执行 .sql 文件”。如果你知道你不能那样做,为什么还要问呢?也许更新你的问题,问你想知道什么。
标签: python python-3.x oracle cx-oracle