From 64b9cf408b484fe0be94a1097739e55e5f887718 Mon Sep 17 00:00:00 2001 From: Andrew nuark G Date: Sun, 12 Mar 2023 01:03:53 +0700 Subject: [PATCH] Add tables metadata listing --- src/based/__init__.py | 3 --- src/based/db.py | 12 +++++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/based/__init__.py b/src/based/__init__.py index 3668c56..3dc1f76 100644 --- a/src/based/__init__.py +++ b/src/based/__init__.py @@ -1,4 +1 @@ __version__ = "0.1.0" - -from .db import * -from .columns import * diff --git a/src/based/db.py b/src/based/db.py index 394d80e..da35bf4 100644 --- a/src/based/db.py +++ b/src/based/db.py @@ -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( """