python 特里诺- Catalog仅支持使用自动提交的写入:< catalog_name>-特里诺dbapi

643ylb08  于 2024-01-05  发布在  Python
关注(0)|答案(1)|浏览(164)

当我尝试连接postgres RDS数据库使用特里诺服务器,使用目录.
我得到这个错误:

  1. trino.exceptions.TrinoUserError: TrinoUserError(type=USER_ERROR, name=AUTOCOMMIT_WRITE_CONFLICT, message="Catalog only supports writes using autocommit: <catalog_name>", query_id=20240103_105150_00001_w6b9p)

字符串
下面是我的Python代码:

  1. from trino.dbapi import connect
  2. from trino.auth import BasicAuthentication
  3. from trino.transaction import IsolationLevel
  4. with connect(
  5. host="localhost",
  6. port=8080,
  7. user="username",
  8. auth=BasicAuthentication("username", "password"),
  9. http_scheme="https",
  10. isolation_level=IsolationLevel.SERIALIZABLE,
  11. verify=False,
  12. catalog="my_catalog_name"
  13. ) as conn:
  14. cur = conn.cursor()
  15. cur.execute('INSERT INTO sometable VALUES (4, 5, 6)')


这是我目录:

  1. connector.name=postgresql
  2. connection-url=jdbc:postgresql://host:5432/db_name?ssl=true
  3. connection-user=postgres
  4. connection-password=password


我希望能解决这个问题!

t5zmwmid

t5zmwmid1#

错误消息表明您正在使用的目录(“my_catalog_name”)仅支持使用自动提交的写入。您需要修改Python代码以在执行SQL语句时使用自动提交。

  1. from trino.dbapi import connect
  2. from trino.auth import BasicAuthentication
  3. # Use the `isolation_level` parameter to set autocommit
  4. with connect(
  5. host="localhost",
  6. port=8080,
  7. user="username",
  8. auth=BasicAuthentication("username", "password"),
  9. http_scheme="https",
  10. isolation_level="AUTOCOMMIT", # Set to AUTOCOMMIT for autocommit mode
  11. verify=False,
  12. catalog="my_catalog_name"
  13. ) as conn:
  14. cur = conn.cursor()
  15. cur.execute('INSERT INTO sometable VALUES (4, 5, 6)')

字符串

展开查看全部

相关问题