Skip to content

Instantly share code, notes, and snippets.

@adamfast
Created October 5, 2012 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adamfast/3842023 to your computer and use it in GitHub Desktop.
Save adamfast/3842023 to your computer and use it in GitHub Desktop.
def create_spatial_database_template():
sudo("""createdb -E UTF8 template_postgis -U postgres""")
try:
sudo("""createlang -d template_postgis plpgsql -U postgres""")
except:
pass
sudo("""psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql -U postgres""")
sudo("""psql -d template_postgis -f /usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql -U postgres""")
sudo("""psql -d template_postgis -c "GRANT ALL ON geometry_columns TO PUBLIC;" -U postgres""")
sudo("""psql -d template_postgis -c "GRANT ALL ON spatial_ref_sys TO PUBLIC;" -U postgres""")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment