出于某种原因,将Python中的字符串传递给Postgres函数并使用psycopg2游标调用它会导致函数无法识别,因为参数是未知。传递给cursor.callproc的字符串变得未知(psycopg2,python 2.7,postgres 9.3)
的功能很简单,像这样:
CREATE OR REPLACE FUNCTION text_test (some_text text)
RETURNS void AS $$
BEGIN
END;
$$ LANGUAGE plpgsql;
在Python端,我有:
cursor.callproc("text_test", ("test",))
而且我得到以下错误:
psycopg2.ProgrammingError: function text_test(unknown) does not exist
LINE 1: SELECT * FROM text_test('test')
^
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
为什么这只会发生在字符串,我需要做什么才能让函数成功接受字符串?由于某些原因,数字数据类型不受此问题影响。
它的工作,谢谢你! – Teboto 2015-02-09 21:11:52