Beispiel #1
0
def create(silent=False):
    """ Create the geometry model from the geometry__country_level0 table """
    from openspending.core import db
    from openspending.model.country import Country

    result = db.engine.execute("SELECT \
                        country_level0.gid as gid \
                        FROM public.geometry__country_level0 as country_level0;"
                               )

    for row in result:
        gid = row['gid']

        #check if it already exists and don't overwrite
        if Country.by_gid(gid):
            if not silent:
                log.info("Found existing gid " + str(gid) +
                         ".  Will not replace.")
            continue

        tempcountry = Country(gid)

        db.session.add(tempcountry)
        db.session.commit()