mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-11 01:27:58 +01:00
pyln: Delete psql DBs after testing
This commit is contained in:
parent
0924b477b2
commit
95eb868047
1 changed files with 13 additions and 0 deletions
|
@ -51,6 +51,9 @@ class Sqlite3Db(object):
|
|||
c.close()
|
||||
db.close()
|
||||
|
||||
def stop(self):
|
||||
pass
|
||||
|
||||
|
||||
class PostgresDb(object):
|
||||
def __init__(self, dbname, port):
|
||||
|
@ -88,6 +91,15 @@ class PostgresDb(object):
|
|||
with self.conn, self.conn.cursor() as cur:
|
||||
cur.execute(query)
|
||||
|
||||
def stop(self):
|
||||
"""Clean up the database.
|
||||
"""
|
||||
self.conn.close()
|
||||
conn = psycopg2.connect("dbname=postgres user=postgres host=localhost port={self.port}")
|
||||
cur = conn.cursor()
|
||||
cur.execute("DROP DATABASE {};".format(self.dbname))
|
||||
cur.close()
|
||||
|
||||
|
||||
class SqliteDbProvider(object):
|
||||
def __init__(self, directory: str) -> None:
|
||||
|
@ -208,3 +220,4 @@ class PostgresDbProvider(object):
|
|||
# [1] https://www.postgresql.org/docs/9.1/server-shutdown.html
|
||||
self.proc.send_signal(signal.SIGINT)
|
||||
self.proc.wait()
|
||||
shutil.rmtree(self.pgdir)
|
||||
|
|
Loading…
Add table
Reference in a new issue