Esempio 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()
Esempio 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()
Esempio n. 3
0
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()
            )

        cursor.execute(
            'INSERT INTO users(\
                name, nationality, latitude, longitude)\
                    VALUES(%s, %s, %s, %s) ', (
                        name, nationality, random_lat, random_long))

db.commit()
db.close()
logging.info('Exiting')