0
私はPythonからPostgresの中で関数を作成しようとしています。私のPostgresデータベースへの接続はPsycopg 2を使用し、他のインスタンスでは正常に接続します。コード:PythonでPostgres関数を作成する
pg_cursor.execute('CREATE OR REPLACE FUNCTION %s.fix_geometry(geometry) \
RETURNS SETOF geometry AS\
$BODY$\
SELECT geom the_geom\
FROM \
(\
SELECT (st_dump(st_buffer(st_snaptogrid(st_makevalid(the_geom), 0.5), 0))).geom\
FROM (SELECT geom the_geom FROM st_dump(st_snaptogrid($1, 0.5))) a\
) b\
WHERE geometrytype(geom) = \'POLYGON\' AND st_area(geom) >= 0.01;\
$BODY$\
LANGUAGE sql VOLATILE\
COST 100\
ROWS 1000;' %(schema)) #line 84
pg_connection.commit()
pg_cursor.execute('ALTER FUNCTION %s.fix_geometry(geometry) OWNER TO analysis' % (schema))
pg_connection.commit()
私はエラーを取得する:私はpgAdminでのコードを実行すると
line 84, in
ROWS 1000;' %(schema))
ProgrammingError: type geometry does not exist
それが正常に実行されます。私は何が欠けていますか?
は、Python 2.7、Postgresの9.3