1

sqlparse モジュールを使用して、特定の sql ステートメントからヒットしたすべてのテーブルを抽出する関数を作成しました。

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;

この方法で関数を実行すると:

select my_function('select foo from bar');

戻り値:bar

この方法で関数を実行すると:

select my_column, my_function(my_column) from schema.my_table;

次のエラーで失敗します。

エラー: XX000: ImportError: モジュール名 sqlparse がありません (plpython.c:5038)

フィードバックをお待ちしております。

4

0 に答える 0