I have a created a function that utilizes the sqlparse module to extract all of the tables hit from any given sql statement:
create or replace function my_function(x text) returns text
as $$
import sqlparse
from collections import namedtuple
from sqlparse.sql import IdentifierList, Identifier, Function
from sqlparse.tokens import Keyword, DML, Puncutation
*the rest of my parser program*
$$ language plpythonu;
When I execute the function this way:
select my_function('select foo from bar');
It returns: bar
When I execute the function this way:
select my_column, my_function(my_column) from schema.my_table;
It fails with:
ERROR: XX000: ImportError: No module name sqlparse (plpython.c:5038)
Any feedback will be appreciated.