def add_extensions(self):
"""If not already added, add extensions required by Ravel (plpythonu,
postgis, pgrouting)"""
try:
self.cursor.execute("SELECT 1 FROM pg_catalog.pg_namespace n JOIN " +
"pg_catalog.pg_proc p ON pronamespace = n.oid " +
"WHERE proname = 'pgr_dijkstra';")
fetch = self.cursor.fetchall()
if fetch == []:
self.cursor.execute("CREATE EXTENSION IF NOT EXISTS plpythonu;")
self.cursor.execute("CREATE EXTENSION IF NOT EXISTS postgis;")
self.cursor.execute("CREATE EXTENSION IF NOT EXISTS pgrouting;")
self.cursor.execute("CREATE EXTENSION plsh;")
logger.debug("created extensions")
except psycopg2.DatabaseError, e:
logger.warning("error loading extensions: %s", self.fmt_errmsg(e))
评论列表
文章目录