I have installed PostGIS on the Ubuntu 14.04 server using:
$ sudo aptitude install postgresql-9.3-postgis-2.1
There is an init.sql file included with the web app to setup the database:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* clean up because I got sick of all this */ | |
drop table if exists rooftops; | |
drop role if exists sunlight; | |
/* The role that sunlight will log in as. */ | |
create role sunlight with password 'H3YCOOLK1D1STH1SYOU' login; | |
/* The main table. Stores all the rooftops. */ | |
create table rooftops ( | |
id serial primary key, | |
shape geometry not null, | |
building_area real, | |
useable_build_area real, | |
percent_usable real, | |
kwhs real, | |
system_size_kw real, | |
savings integer | |
); | |
grant all privileges on table rooftops to sunlight; | |
grant all privileges on rooftops_id_seq to sunlight; |
When I run it with:
$ sudo su postgresI get an error:
$ psql -d postgres -a -f init.sql
psql:init.sql:17: ERROR: type "geometry" does not existA post on stack overflow told me I needed to run:
$ psql -d postgres -c "CREATE EXTENSION postgis;"After running this, init.sql ran without error, but 'make run' has a new problem:
$ make runI ran:
python3 httpserver.py
Traceback (most recent call last):
File "httpserver.py", line 17, in <module>
host=app.config["DBHOST"]
File "/usr/lib/python3/dist-packages/psycopg2/__init__.py", line 179, in connect
connection_factory=connection_factory, async=async)
psycopg2.OperationalError: FATAL: database "test" does not exist
make: *** [run] Error 1
$ egrep test *and found:
flaskconfig.py:DBNAME = 'test'After changing 'test' to 'postgres', I have a running server:
$ make runConnecting to it from the browser on my desktop machine, I see:
python3 httpserver.py
[15-07-11 11:57:54][NOTE] Starting server
* Running on http://0.0.0.0:5000/
* Restarting with reloader
[15-07-11 11:57:54][NOTE] Starting server
My next task will be to populate the database with data.
No comments:
Post a Comment