diff options
author | Rob Austein <sra@hactrn.net> | 2007-08-24 17:15:49 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2007-08-24 17:15:49 +0000 |
commit | 394c034dedeb82ef283c35c911b53e735c05560c (patch) | |
tree | e20f5beb13d9992d0c7ad4f8f2cdf322b22362a0 | |
parent | 9305c8129786dd81a64aac9729fbfa70b932bcbc (diff) |
Drive from config file
svn path=/scripts/test-sql.py; revision=904
-rw-r--r-- | scripts/test-sql.py | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/scripts/test-sql.py b/scripts/test-sql.py index fa179a00..3bf08b19 100644 --- a/scripts/test-sql.py +++ b/scripts/test-sql.py @@ -2,32 +2,36 @@ import MySQLdb, ConfigParser -cfg = ConfigParser.ConfigParser() -cfg.read("re.conf") +def test(filename, section): -db = MySQLdb.connect(user = "rpki", db = "rpki", passwd = cfg.get("rpki", "password")) -cur = db.cursor() + print "[Checking " + filename + "]\n" -def duh(cmd, header): - cur.execute(cmd) - print header - print "-" * len(header) - print cur.description - for i in cur.fetchall(): - print i[0] - print + cfg = ConfigParser.ConfigParser() + cfg.read(filename) -duh("SHOW DATABASES", "Databases") + db = MySQLdb.connect(user = cfg.get(section, "username"), + db = cfg.get(section, "database"), + passwd = cfg.get(section, "password")) -duh("SELECT DATABASE()", "Current database") + cur = db.cursor() -duh("USE rpki", "Select database") + def duh(db, cmd, header): + cur.execute(cmd) + print header + print "-" * len(header) + print cur.description + for i in cur.fetchall(): + print i[0] + print -duh("SELECT DATABASE()", "Current database") + duh(db, "SHOW DATABASES", "Databases") + duh(db, "SELECT DATABASE()", "Current database") + duh(db, "SHOW TABLES", "Current tables") -duh("SHOW TABLES", "Current tables") + db.close() -print MySQLdb.Timestamp(2007,6,9,9,45,51), MySQLdb.DateFromTicks(1000), MySQLdb.Binary("Hi, Mom!"), MySQLdb.STRING, MySQLdb.BINARY, MySQLdb.NUMBER, MySQLdb.NULL +print MySQLdb.Timestamp(2007,6,9,9,45,51), MySQLdb.DateFromTicks(1000), \ + MySQLdb.Binary("Hi, Mom!"), MySQLdb.STRING, MySQLdb.BINARY, MySQLdb.NUMBER, MySQLdb.NULL, "\n" -cur.close() -db.close() +test("re.conf", "rpki") +test("irbe.conf", "irdb") |