Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
1 Odpovědět
1465 Zobrazení

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()



Avatar
Zrušit
Nejlepší odpověď

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. 

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
dub 22
3892
1
bře 22
3286
5
bře 20
18129
2
kvě 17
10393
2
bře 15
7745