diff options
author | Rob Austein <sra@hactrn.net> | 2012-11-15 22:13:53 +0000 |
---|---|---|
committer | Rob Austein <sra@hactrn.net> | 2012-11-15 22:13:53 +0000 |
commit | 756fdbe0d7eda1e98663c62bb3e57f2c18e88ee1 (patch) | |
tree | c0af81a5987e9859d12a0323d0d240f58d8b2f36 /rpkid/tests/sql-dumper.py | |
parent | 713507be1695d8f2f278ab925d58defc58eff2aa (diff) | |
parent | 11f3b8df179a16ebe1446dab620522ac97e3c327 (diff) |
Merge tk274 performance work back to trunk. Closes #274.
svn path=/trunk/; revision=4878
Diffstat (limited to 'rpkid/tests/sql-dumper.py')
-rw-r--r-- | rpkid/tests/sql-dumper.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/rpkid/tests/sql-dumper.py b/rpkid/tests/sql-dumper.py index cff62d4f..e4bb1a28 100644 --- a/rpkid/tests/sql-dumper.py +++ b/rpkid/tests/sql-dumper.py @@ -3,7 +3,7 @@ Dump backup copies of SQL tables used by these programs. $Id$ -Copyright (C) 2009--2010 Internet Systems Consortium ("ISC") +Copyright (C) 2009--2012 Internet Systems Consortium ("ISC") Permission to use, copy, modify, and distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -18,7 +18,9 @@ OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. """ -import subprocess, rpki.config +import subprocess +import rpki.config +from rpki.mysql_import import MySQLdb cfg = rpki.config.parser(None, "yamltest", allow_missing = True) @@ -28,5 +30,14 @@ for name in ("rpkid", "irdbd", "pubd"): password = cfg.get("%s_sql_password" % name, "fnord") cmd = ["mysqldump", "-u", username, "-p" + password, "--databases"] - cmd.extend("%s%d" % (name[:4], i) for i in xrange(12)) + + db = MySQLdb.connect(user = username, passwd = password) + cur = db.cursor() + + cur.execute("SHOW DATABASES") + cmd.extend(r[0] for r in cur.fetchall() if r[0][:4] == name[:4] and r[0][4:].isdigit()) + + cur.close() + db.close() + subprocess.check_call(cmd, stdout = open("backup.%s.sql" % name, "w")) |