mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 23:24:27 +01:00
pytest: Have the db_query helper work on a copy of the DB
Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
committed by
Rusty Russell
parent
24ba5d6250
commit
45c935ddba
@@ -338,7 +338,12 @@ class LightningNode(object):
|
||||
return [c for c in self.rpc.listchannels()['channels'] if c['active']]
|
||||
|
||||
def db_query(self, query):
|
||||
db = sqlite3.connect(os.path.join(self.daemon.lightning_dir, "lightningd.sqlite3"))
|
||||
from shutil import copyfile
|
||||
orig = os.path.join(self.daemon.lightning_dir, "lightningd.sqlite3")
|
||||
copy = os.path.join(self.daemon.lightning_dir, "lightningd-copy.sqlite3")
|
||||
copyfile(orig, copy)
|
||||
|
||||
db = sqlite3.connect(copy)
|
||||
db.row_factory = sqlite3.Row
|
||||
c = db.cursor()
|
||||
c.execute(query)
|
||||
|
||||
Reference in New Issue
Block a user