Example #1
0
 def test_show_tables(self):
   shutil.copy('fixtures/landbank_branches.sqlite','/tmp/test.db')
   h = DumpTruck(dbname = '/tmp/test.db')
   self.assertSetEqual(h.tables(),set(['blocks','branches']))
Example #2
0
 def test_no_rows_first_insert(self):
   "Nothing happens if no rows are inserted to a table that isn't there."
   dt = DumpTruck(dbname = '/tmp/test.db')
   dt.insert([], 'ninety')
   self.assertSetEqual(dt.tables(), set())
   dt.close()
Example #3
0
 def test_save(self):
   h = DumpTruck(dbname = '/tmp/test.db')
   h.insert({'firstname': 'Robert', 'lastname': 'LeTourneau'}, 'foo')
   h.drop('foo')
   self.assertEqual(h.tables(), set([]))
   h.close()
Example #4
0
DEFAULT_LOCATION = "us-east-1"
DEFAULT_DESTINATION = "s3"

# Read default config file
config = {}
if os.path.isfile(CONFIG_FILE):
    log.debug("Try loading default config file: {0}".format(CONFIG_FILE))
    config = yaml.load(open(CONFIG_FILE))
    if config:
        log.debug("Config loaded")

# DumpTruck initialization
dump_truck = DumpTruck(dbname=os.path.expanduser("~/.bakthat.dt"), vars_table="config")

if not "backups" in dump_truck.tables():
    # We initialize DumpTruck, with dummy data that won't be inserted.
    dump_truck.create_table(
        {
            "stored_filename": "filename.20130227205616.tgz",
            "size": 1,
            "metadata": {"is_enc": False},
            "backup_date": 1361994976,
            "filename": "filename",
            "backend": "s3",
            "is_deleted": False,
            "last_updated": 1361994976,
            "tags": [],
            "backend_hash": "backendhash",
        },
        "backups",
Example #5
0
def main():
    # Connect to the database.
    from dumptruck import DumpTruck
    dt = DumpTruck('/tmp/appgen.db', auto_commit = False)
    if 'dataset' not in dt.tables():
        dt = build_db()
Example #6
0
 def test_show_tables(self):
     shutil.copy("fixtures/landbank_branches.sqlite", "/tmp/test.db")
     h = DumpTruck(dbname="/tmp/test.db")
     self.assertSetEqual(h.tables(), set(["blocks", "branches"]))
Example #7
0
 def test_save(self):
     h = DumpTruck(dbname="/tmp/test.db")
     h.insert({"firstname": "Robert", "lastname": "LeTourneau"}, "foo")
     h.drop("foo")
     self.assertEqual(h.tables(), set([]))
     h.close()