fix(smbdb): fix clear_database query
parent
17eda1767d
commit
1e5fec0b75
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
import logging
|
||||
from sqlalchemy import MetaData, func, inspect, Table, select, insert, update, delete
|
||||
from sqlalchemy import MetaData, func, Table, select, insert, update, delete
|
||||
from sqlalchemy.dialects.sqlite import insert as sqlite_upsert
|
||||
from sqlalchemy.exc import IllegalStateChangeError
|
||||
from sqlalchemy.orm import sessionmaker, scoped_session
|
||||
|
@ -15,11 +15,6 @@ import warnings
|
|||
warnings.filterwarnings("ignore", category=SAWarning)
|
||||
|
||||
|
||||
def get_table_names(conn):
|
||||
inspector = inspect(conn)
|
||||
return inspector.get_table_names()
|
||||
|
||||
|
||||
class database:
|
||||
def __init__(self, db_engine):
|
||||
self.ComputersTable = None
|
||||
|
@ -856,6 +851,5 @@ class database:
|
|||
return results
|
||||
|
||||
def clear_database(self):
|
||||
for table in self.metadata.tables:
|
||||
self.conn.query(self.metadata.tables[table]).delete()
|
||||
self.conn.commit()
|
||||
for table in self.metadata.sorted_tables:
|
||||
asyncio.run(self.conn.execute(table.delete()))
|
||||
|
|
Loading…
Reference in New Issue