Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
595 B
0
Indexable
Never
    def get_record_amount(
            self,
            table_name: str = "imdbdata",
    ) -> int:
        session = self.connect()
        query = f"SELECT COUNT(*) FROM mydatabase.{table_name}"
        result = session.execute(query)
        count = result[0].count
        return count

    def list_tables(self) -> tp.List[str]:
        session = self.connect()
        query = "SELECT table_name FROM system_schema.tables WHERE keyspace_name = 'mydatabase'"
        result = session.execute(query)
        tables = [row.table_name for row in result]
        return tables