Skip to Content
Menu
This question has been flagged
1 Odpoveď
1481 Zobrazenia

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
Zrušiť
Best Answer

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
Zrušiť
Related Posts Replies Zobrazenia Aktivita
1
sep 21
4396
2
apr 24
10680
4
apr 25
3877
0
feb 25
1611
2
jan 25
8232