Bỏ qua để đến Nội dung
Menu
Câu hỏi này đã bị gắn cờ
1 Trả lời
1299 Lượt xem

We have a dedicated Odoo.sh server.

It is configured to allow direct SQL access:

odoosh-sql-access init

 
We have been able to successfully connect but can't run any SQL, even a simple SELECT:

import psycopg2

connection = psycopg2.connect(database="db",
user="user",
password="password",
host="host",
port="5432",
sslmode="require")

cursor = connection.cursor() # ✅ this works ✅

cursor.execute("SELECT * FROM res_partner;") # ❌ this FAILS ❌

connection.close()



Ảnh đại diện
Huỷ bỏ
Câu trả lời hay nhất

Transactions are not supported with the direct access method.

You need to modify your psycopg2.connect call to add:

autocommit=True

Without this option, psycopg2 will implicitly start a transaction when calling execute which is not allowed by the server. 

Ảnh đại diện
Huỷ bỏ
Bài viết liên quan Trả lời Lượt xem Hoạt động
1
thg 4 22
3786
1
thg 3 22
3148
5
thg 3 20
17876
2
thg 5 17
10248
2
thg 3 15
7567