mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-12 02:08:15 +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()
|
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)
|
||||||
|
|
Loading…
Add table
Reference in a new issue