Esempio n. 1
0
            # Single-column primary index. Validate type.
            column_info = dbh.ExecuteOrDie(
                "SHOW COLUMNS FROM `%s`.`%s` LIKE %%(column)s" % (table["TABLE_SCHEMA"], table["TABLE_NAME"]),
                {"column": indexes["PRIMARY"]["columns"][0]},
            )
            if column_info[0]["Null"] == "YES":
                print "`%s`.`%s`: ID column %s is nullable" % (
                    table["TABLE_SCHEMA"],
                    table["TABLE_NAME"],
                    column_info[0]["Field"],
                )
            if column_info[0]["Type"] not in ("bigint(20)", "bigint(20) unsigned"):
                print "`%s`.`%s`: ID column %s has invalid type: %s" % (
                    table["TABLE_SCHEMA"],
                    table["TABLE_NAME"],
                    column_info[0]["Field"],
                    column_info[0]["Type"],
                )


def main(unused_argv):
    assert FLAGS.db, "Please pass --db"

    with db.Connect(FLAGS.db) as dbh:
        FindDuplicateIndexes(dbh)
        FindNonTransactionalTables(dbh)


if __name__ == "__main__":
    app.run()
Esempio n. 2
0
        return 1

    logging.info('Checking file %s', FLAGS.input)
    fh, size, checksum = _PrepareFile(FLAGS.input)

    dbspec = db.Spec.Parse(FLAGS.dbspec)
    with dbspec.Connect() as dbh:
        if FLAGS.session_init:
            logging.info('Initializing session with: %s', FLAGS.session_init)
            dbh.ExecuteOrDie(FLAGS.session_init)

        if FLAGS.init_state_table:
            logging.info('Setting up the state table')
            InitStateTable(dbh, FLAGS.state_database, FLAGS.state_table, fh,
                           size, checksum)
        else:
            logging.info('Starting the trickle')
            trickler = DbFileTrickler(dbh, FLAGS.utilization_percent,
                                      FLAGS.cycle_time, FLAGS.state_database,
                                      FLAGS.state_table, fh, size, checksum)
            if FLAGS.artificial_batch_cap:
                trickler.SetBatchSizeLimit(FLAGS.artificial_batch_cap)
            trickler.Trickle()

    logging.info('Done')


if __name__ == '__main__':
    FLAGS.logbuflevel = -1
    app.run()