mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-20 15:44:21 +01:00
pyln: Delete psql DBs after testing
This commit is contained in:
@@ -51,6 +51,9 @@ class Sqlite3Db(object):
|
|||||||
c.close()
|
c.close()
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class PostgresDb(object):
|
class PostgresDb(object):
|
||||||
def __init__(self, dbname, port):
|
def __init__(self, dbname, port):
|
||||||
@@ -88,6 +91,15 @@ class PostgresDb(object):
|
|||||||
with self.conn, self.conn.cursor() as cur:
|
with self.conn, self.conn.cursor() as cur:
|
||||||
cur.execute(query)
|
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):
|
class SqliteDbProvider(object):
|
||||||
def __init__(self, directory: str) -> None:
|
def __init__(self, directory: str) -> None:
|
||||||
@@ -208,3 +220,4 @@ class PostgresDbProvider(object):
|
|||||||
# [1] https://www.postgresql.org/docs/9.1/server-shutdown.html
|
# [1] https://www.postgresql.org/docs/9.1/server-shutdown.html
|
||||||
self.proc.send_signal(signal.SIGINT)
|
self.proc.send_signal(signal.SIGINT)
|
||||||
self.proc.wait()
|
self.proc.wait()
|
||||||
|
shutil.rmtree(self.pgdir)
|
||||||
|
|||||||
Reference in New Issue
Block a user