SqlAlchemy - 从 oracle 数据库中检索长文本

SqlAlchemy - Retrieve long text from oracle db

我正在尝试 运行 几个 queries/stored 会 return 长文本 (varchar2/clob) 的过程,例如:Table/View/etc ddl。将获取长文本,进行一些操作并存储在平面文件中。

我得到的输出低于整个内容的 t运行 分类版本(突出显示):

("DROP VIEW <<view>>;\n\n/* Formatted on 27/05/2022 7:08:33 PM (QP5 v5.354) */\nCREATE OR REPLACE FORCE 
VIEW <<view>> ... **(1097 characters truncated)** ... tx', '<<some value>>'),\n                                     'YYYYMMDD');
\n\n\nGRANT <<rights>>> ON <<view>> TO <<user>>;\n",)

我正在使用以下代码:

conn_db = create_engine('oracle://<<user>>:<<pass>>@<<db_service>>')`
with conn_db.connect() as connection:
    res = connection.execute("<<query/proc>>")
    for row in res:
        print(row) # this returns the above output

我尝试在创建引擎时设置数组大小,但没有成功。

print(row) 正在截断字符串以供显示。实际字符串不受影响:

import sqlalchemy as sa

engine = sa.create_engine("oracle+cx_oracle://scott:tiger@192.168.0.199/?service_name=xepdb1")

s = " ".join(["spam" for i in range(200)])
with engine.connect() as conn:
    row = conn.exec_driver_sql("SELECT :s AS spam FROM DUAL", {"s": s}).one()
    print(row)
    # ('spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam ... (701 characters truncated) ... spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam',)
    #
    # [scroll right to see "... (701 characters truncated) ..."]
    #
    spam = row.spam
    print(len(spam))  # 999
    print(spam)
    # spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam spam