Example #1
0
 def create_sql_engine(cls, url_or_con, table):
     con = ConnectionHandler.get_connection(url_or_con)
     if isinstance(con, DuckDBPyConnection):
         return DuckDBEngine(con, table)
     elif isinstance(con, Connection):
         return SQLAlchemyEngine(con, table)
     else:
         raise UnsupportedConnectionObjectException(f"Connection object '{con.__class__.__name__}' not supported.")
Example #2
0
 def create_sql_metadata_repository(cls,
                                    url_or_con) -> SQLMetadataRepository:
     con = ConnectionHandler.get_connection(url_or_con)
     if isinstance(con, DuckDBPyConnection):
         return DuckDBMetadataRepository(con)
     elif isinstance(con, Connection):
         return SQLAlchemyMetadataRepository(con)
     else:
         raise UnsupportedConnectionObjectException(
             f"Connection object {con} not supported.")
Example #3
0
    def __init__(self, data: DataFrame, no_sharing=False):
        super().__init__()
        con = ConnectionHandler.get_connection("duckdb://:memory:")

        # activate multiprocessing with available cpu's but one
        con.execute(f"PRAGMA threads={multiprocessing.cpu_count()}")

        # register df
        con.register("data", data)

        self.engine = DuckDBEngine(con, "data", no_sharing=no_sharing)
        self.data = data
        self.table = "data"