Postgres function raising error when calling from Python script but running fine in PgAdmin

2.2k Views Asked by At

I have a postgres function called 'medrealize()' inside which i am creating temp table and creating index for temp tables using below lines

CREATE INDEX SQLOPS_RefICD_ICD10_idx ON  t$SQLOPS_RefICD_ICD10 USING gist (code gist_trgm_ops );
CREATE INDEX regexes_idx ON  t$regexes  USING gist (icdregex  gist_trgm_ops );

When calling the function from pgadmin, the function runs without any issues. But when calling the function from python using

cursor.execute("BEGIN")
cursor.execute("CALL medrealize();")
cursor.execute("COMMIT")

I am getting below error

operator class \"gist_trgm_ops\" does not exist for access method \"gist\"\

Any idea why its running fine when calling from PgAdmin and raising error when calling from Python?

1

There are 1 best solutions below

0
On

Did you install the trigram index extension in your database ?

CREATE EXTENSION IF NOT EXISTS pg_trgm;  

If not, try to add it inside your function .