İçereği Atla
Menü
Bu soru işaretlendi
1 Cevapla
1374 Görünümler

Hello,

in odoo16e in Osoo sh, I want to get info from an external database, in odoo sh i have postgresql (14.12) and the database that i want to get info, has postgresql (9.6.19)

I'm trying using psycopg2, in my odoo local i can access successfully, but not in odoo sh, i get this error: connection to server at "xxx.xx.xxx.xxx", port xxxx failed: FATAL: unrecognized configuration parameter "jit" 


my odoo local has postgresql (16.3)


My code is: 

import psycopg2

from odoo import api, fields, models,


class ZkMachine(models.Model): 

​_name = 'zk.machine'

​ def try_connection(self):

​ db_params = {

​ 'dbname': self.database,

​ 'user': self.user_name,

​ 'password': self.password,

​ 'host': self.name,

​ 'port': self.port_no

​ }

​ dsn = f"dbname={db_params['dbname']} user={db_params['user']} password={db_params['password']} host={db_params['host']} port={db_params['port']}"

​ try:

​ conn = psycopg2.connect(dsn)

​ if conn:

​ msg = f'Te has conectado exitosamente a {self.database}'

​ conn.close()

​ except psycopg2.Error as e:

​ msg = f"No se ha podido establecer la conexión: {e}"

​ return self._message_user('danger', msg)

​ except Exception as ex:

​ msg = f"Error desconocido: {ex}"

​ return self._message_user('danger', msg)


Could someone help me to solve this??


Thx in advance

Avatar
Vazgeç
En İyi Yanıt

Hi,

As per the information given the error you're encountering in Odoo SH happens because Odoo SH's PostgreSQL client (psycopg2) is newer (supporting PostgreSQL 14 features like JIT), while your target external PostgreSQL server is 9.6, which does not recognize newer parameters like jit.


This issue arises not from your code, but from the PostgreSQL client's default settings when connecting, which may try to use features that don't exist in PostgreSQL 9.6.


To solve this issue you need to disable JIT explicitly when making the connection. 


Hope it helps.



Avatar
Vazgeç
İlgili Gönderiler Cevaplar Görünümler Aktivite
1
Eyl 21
4265
2
Nis 24
10534
4
Nis 25
3680
0
Şub 25
1368
2
Oca 25
7825