Add tables metadata listing

This commit is contained in:
Andrew 2023-03-12 01:03:53 +07:00
parent 2a612a596d
commit 64b9cf408b
2 changed files with 9 additions and 6 deletions

View file

@ -1,4 +1 @@
__version__ = "0.1.0"
from .db import *
from .columns import *

View file

@ -1,9 +1,10 @@
from typing import Any, NamedTuple
from typing import Any
from psycopg import Connection
from psycopg.rows import namedtuple_row, dict_row
from psycopg.rows import dict_row
from psycopg.sql import SQL, Identifier, Literal
from psycopg_pool import ConnectionPool
from columns import *
from .columns import *
class _ExtendedConnection(Connection):
@ -83,6 +84,11 @@ class DBConnector:
[ColumnCondition("table_name", table_name, isString=True, isLike=True)],
)
def tables(self):
stmt = SQL("SELECT * FROM tables_metadata")
with self.connection() as conn:
return conn.execute(stmt).fetchall()
def tableExists(self, table_name: str):
stmt = SQL(
"""