Hello, I am trying to execute this code from a server action but it is returning an error and I can't find how to solve it.
for record in records:
if record.x_disponibilidad:
import psicopg2
host = "localhost"
port = "5432"
user = "postgres"
pas = "postgres"
db = "SAG070524"
connection_conf = """
host=%s user=%s password=%s dbname=%s
""" % (host,port,pas,db)
connection = psicopg2.connect(connection_conf)
cursor = connection.cursor()
query="update x_reg_asignaciones set x_sec = 1"
cursor.execute(query)
cursor.close()
connection.close()
This is the error that is returning me
forbidden opcode(s) in 'for record in records:\n  if 
record.x_disponibilidad:   \n    import psicopg2\n    host = 
"localhost"\n    port = "5432"\n    user = "postgres"\n    pas = 
"postgres"\n    db = "SAG070524"\n        \n    connection_conf = """ \n
        host=%s user=%s password=%s dbname=%s \n        """ % 
(host,port,pas,db)\n        \n    connection = 
psicopg2.connect(connection_conf)\n    cursor = connection.cursor()\n   
   \n    query="update x_reg_asignaciones set x_sec = 1"\n    
cursor.execute(query)\n    cursor.close()\n    connection.close()': 
IMPORT_NAME
