Tutorial¶
Installation¶
You can install the library using pip.
pip install gcudm
If you need a specific version of the data model, specify it when you install.
pip install gcudm==0.0.1
Build Your Database¶
gcudm is built on GeoAlchemy 2 (and SqlAlchey). We try not to come between you and the underlying platforms, so if you’re familiar with these frameworks everything should work as you expect.
One convenience that is provided is the gcudm.model.load()
function
which you can call to make sure that all the modules that define
object-relational mappings
are loaded. You should do this before you create your database tables from
the model to make sure that all the classes that implement the
declarative base
are loaded.
from gcudm.base import Base
import gcudm.model
from sqlalchemy import create_engine
# Load the entire model.
gcudm.model.load()
# The rest is standard SQLAlchemy...
# ...just create an engine.
engine = create_engine(
'postgresql://<user>:<password>@<host>/<your-database>',
echo=True)
# Now create the tables in your database.
Base.metadata.create_all(engine)