Ejemplo n.º 1
0
        def __purge(self):
            db = Database()
            cursor = db.cursor()

            cursor.execute("""SELECT COUNT(*)
                                FROM changesets
                                JOIN customchangesets ON (customchangesets.changeset=changesets.id)
                               WHERE time < NOW() - INTERVAL '3 months'""")
            npurged = cursor.fetchone()[0]

            if npurged:
                self.info("purging %d old custom changesets" % npurged)

                cursor.execute("DELETE FROM changesets USING customchangesets WHERE id=changeset AND time < NOW() - INTERVAL '3 months'")
                db.commit()

            db.close()
Ejemplo n.º 2
0
        def __purge(self):
            db = Database()
            cursor = db.cursor()

            cursor.execute("""SELECT COUNT(*)
                                FROM changesets
                                JOIN customchangesets ON (customchangesets.changeset=changesets.id)
                               WHERE time < NOW() - INTERVAL '3 months'""")
            npurged = cursor.fetchone()[0]

            if npurged:
                self.info("purging %d old custom changesets" % npurged)

                cursor.execute(
                    "DELETE FROM changesets USING customchangesets WHERE id=changeset AND time < NOW() - INTERVAL '3 months'"
                )
                db.commit()

            db.close()
Ejemplo n.º 3
0
    NATIONALITIES[2]: lv_coordinates,
    NATIONALITIES[3]: lt_coordinates,
    NATIONALITIES[4]: ua_coordinates
}

uniq_names = get_uniq_names(NAMES_FILE)

logging.debug('by max_latitude: %s', by_coordinates.max_latitude())
logging.debug("by min_latitude: %s", by_coordinates.min_latitude())
logging.debug("by max_longitude: %s", by_coordinates.max_longitude())
logging.debug("by min_longitude: %s", by_coordinates.max_longitude())

logging.info('Creating the database connection')
try:
    db = Database()
    cursor = db.cursor()
    db.create_tables()
except Exception as e:
    logging.CRITICAL("Unable to create the database: %s", e)


for nationality in NATIONALITIES:
    for i in range(1000):
        name = random.choice(uniq_names)
        random_lat = random.uniform(
            NATIONAL_COORDINATES[nationality].min_latitude(),
            NATIONAL_COORDINATES[nationality].max_latitude()
            )
        random_long = random.uniform(
            NATIONAL_COORDINATES[nationality].min_longitude(),
            NATIONAL_COORDINATES[nationality].max_longitude()