Add database management to terrain.py