diff --git a/connectorx-python/connectorx/__init__.py b/connectorx-python/connectorx/__init__.py index e27517fc3..8989cce97 100644 --- a/connectorx-python/connectorx/__init__.py +++ b/connectorx-python/connectorx/__init__.py @@ -48,7 +48,7 @@ def rewrite_conn( - conn: str | Connection, protocol: Protocol | None = None + conn: str | ConnectionUrl, protocol: Protocol | None = None ) -> tuple[str, Protocol]: if not protocol: # note: redshift/clickhouse are not compatible with the 'binary' protocol, and use other database @@ -66,7 +66,7 @@ def rewrite_conn( def get_meta( - conn: str | Connection, + conn: str | ConnectionUrl, query: str, protocol: Protocol | None = None, ) -> pd.DataFrame: @@ -91,7 +91,7 @@ def get_meta( def partition_sql( - conn: str | Connection, + conn: str | ConnectionUrl, query: str, partition_on: str, partition_num: int, @@ -125,7 +125,7 @@ def partition_sql( def read_sql_pandas( sql: list[str] | str, - con: str | Connection | dict[str, str] | dict[str, Connection], + con: str | ConnectionUrl | dict[str, str] | dict[str, ConnectionUrl], index_col: str | None = None, protocol: Protocol | None = None, partition_on: str | None = None, @@ -166,7 +166,7 @@ def read_sql_pandas( # default return pd.DataFrame @overload def read_sql( - conn: str | Connection | dict[str, str] | dict[str, Connection], + conn: str | ConnectionUrl | dict[str, str] | dict[str, ConnectionUrl], query: list[str] | str, *, protocol: Protocol | None = None, @@ -179,7 +179,7 @@ def read_sql( @overload def read_sql( - conn: str | Connection | dict[str, str] | dict[str, Connection], + conn: str | ConnectionUrl | dict[str, str] | dict[str, ConnectionUrl], query: list[str] | str, *, return_type: Literal["pandas"], @@ -193,7 +193,7 @@ def read_sql( @overload def read_sql( - conn: str | Connection | dict[str, str] | dict[str, Connection], + conn: str | ConnectionUrl | dict[str, str] | dict[str, ConnectionUrl], query: list[str] | str, *, return_type: Literal["arrow", "arrow2"], @@ -207,7 +207,7 @@ def read_sql( @overload def read_sql( - conn: str | Connection | dict[str, str] | dict[str, Connection], + conn: str | ConnectionUrl | dict[str, str] | dict[str, ConnectionUrl], query: list[str] | str, *, return_type: Literal["modin"], @@ -221,7 +221,7 @@ def read_sql( @overload def read_sql( - conn: str | Connection | dict[str, str] | dict[str, Connection], + conn: str | ConnectionUrl | dict[str, str] | dict[str, ConnectionUrl], query: list[str] | str, *, return_type: Literal["dask"], @@ -235,7 +235,7 @@ def read_sql( @overload def read_sql( - conn: str | Connection | dict[str, str] | dict[str, Connection], + conn: str | ConnectionUrl | dict[str, str] | dict[str, ConnectionUrl], query: list[str] | str, *, return_type: Literal["polars", "polars2"], @@ -248,7 +248,7 @@ def read_sql( def read_sql( - conn: str | Connection | dict[str, str] | dict[str, Connection], + conn: str | ConnectionUrl | dict[str, str] | dict[str, ConnectionUrl], query: list[str] | str, *, return_type: Literal[ @@ -501,16 +501,16 @@ def try_import_module(name: str): ) -class Connection(Generic[_BackendT], str): +class ConnectionUrl(Generic[_BackendT], str): @overload def __new__( cls, *, backend: Literal["sqlite"], db_path: str | Path, - ) -> Connection[Literal["sqlite"]]: + ) -> ConnectionUrl[Literal["sqlite"]]: """ - Help to build sqlite connection string. + Help to build sqlite connection string url. Parameters ========== @@ -526,9 +526,9 @@ def __new__( *, backend: Literal["bigquery"], db_path: str | Path, - ) -> Connection[Literal["bigquery"]]: + ) -> ConnectionUrl[Literal["bigquery"]]: """ - Help to build BigQuery connection string. + Help to build BigQuery connection string url. Parameters ========== @@ -549,9 +549,9 @@ def __new__( port: int, database: str = "", database_options: dict[str, str] | None = None, - ) -> Connection[_ServerBackendT]: + ) -> ConnectionUrl[_ServerBackendT]: """ - Help to build server-side backend database connection string. + Help to build server-side backend database connection string url. Parameters ========== @@ -575,9 +575,9 @@ def __new__( def __new__( cls, raw_connection: str, - ) -> Connection: + ) -> ConnectionUrl: """ - Build connection from raw connection string + Build connection from raw connection string url Parameters ========== @@ -597,7 +597,7 @@ def __new__( database: str = "", database_options: dict[str, str] | None = None, db_path: str | Path = "", - ) -> Connection: + ) -> ConnectionUrl: if raw_connection is not None: return super().__new__(cls, raw_connection) diff --git a/connectorx-python/connectorx/tests/test_bigquery.py b/connectorx-python/connectorx/tests/test_bigquery.py index 401500b54..87417500e 100644 --- a/connectorx-python/connectorx/tests/test_bigquery.py +++ b/connectorx-python/connectorx/tests/test_bigquery.py @@ -4,7 +4,7 @@ import pytest from pandas.testing import assert_frame_equal -from .. import read_sql, Connection +from .. import read_sql, ConnectionUrl @pytest.fixture(scope="module") # type: ignore @@ -310,5 +310,5 @@ def test_bigquery_types(bigquery_url: str) -> None: not os.environ.get("BIGQUERY_URL"), reason="Test bigquery only when `BIGQUERY_URL` is set", ) -def test_connection(bigquery_url: str) -> None: - test_bigquery_types(Connection(bigquery_url)) +def test_connection_url(bigquery_url: str) -> None: + test_bigquery_types(ConnectionUrl(bigquery_url)) diff --git a/connectorx-python/connectorx/tests/test_clickhouse.py b/connectorx-python/connectorx/tests/test_clickhouse.py index e56d00d96..e67562ef3 100644 --- a/connectorx-python/connectorx/tests/test_clickhouse.py +++ b/connectorx-python/connectorx/tests/test_clickhouse.py @@ -4,7 +4,7 @@ import pytest from pandas.testing import assert_frame_equal -from .. import read_sql, Connection +from .. import read_sql, ConnectionUrl @pytest.fixture(scope="module") # type: ignore @@ -87,5 +87,5 @@ def test_clickhouse_types(clickhouse_url: str) -> None: not os.environ.get("CLICKHOUSE_URL"), reason="Do not test Clickhouse unless `CLICKHOUSE_URL` is set", ) -def test_connection(clickhouse_url: str) -> None: - test_clickhouse_types(Connection(clickhouse_url)) +def test_connection_url(clickhouse_url: str) -> None: + test_clickhouse_types(ConnectionUrl(clickhouse_url)) diff --git a/connectorx-python/connectorx/tests/test_mssql.py b/connectorx-python/connectorx/tests/test_mssql.py index 58175c838..6c9403396 100644 --- a/connectorx-python/connectorx/tests/test_mssql.py +++ b/connectorx-python/connectorx/tests/test_mssql.py @@ -3,7 +3,7 @@ import pandas as pd import pytest from pandas.testing import assert_frame_equal -from connectorx import Connection +from connectorx import ConnectionUrl from .. import read_sql @@ -498,5 +498,5 @@ def test_mssql_offset(mssql_url: str) -> None: assert_frame_equal(df, expected, check_names=True) -def test_connection(mssql_url: str) -> None: - test_mssql_offset(Connection(mssql_url)) \ No newline at end of file +def test_connection_url(mssql_url: str) -> None: + test_mssql_offset(ConnectionUrl(mssql_url)) \ No newline at end of file diff --git a/connectorx-python/connectorx/tests/test_mysql.py b/connectorx-python/connectorx/tests/test_mysql.py index ef2a20e78..51ffcf168 100644 --- a/connectorx-python/connectorx/tests/test_mysql.py +++ b/connectorx-python/connectorx/tests/test_mysql.py @@ -4,7 +4,7 @@ import pytest from pandas.testing import assert_frame_equal -from .. import read_sql, Connection +from .. import read_sql, ConnectionUrl @pytest.fixture(scope="module") # type: ignore @@ -470,5 +470,5 @@ def test_mysql_cte(mysql_url: str) -> None: assert_frame_equal(df, expected, check_names=True) -def test_connection(mysql_url: str) -> None: - test_mysql_cte(Connection(mysql_url)) +def test_connection_url(mysql_url: str) -> None: + test_mysql_cte(ConnectionUrl(mysql_url)) diff --git a/connectorx-python/connectorx/tests/test_oracle.py b/connectorx-python/connectorx/tests/test_oracle.py index 3640fc587..ef6d8c0f2 100644 --- a/connectorx-python/connectorx/tests/test_oracle.py +++ b/connectorx-python/connectorx/tests/test_oracle.py @@ -4,7 +4,7 @@ import pytest from pandas.testing import assert_frame_equal -from .. import read_sql, Connection +from .. import read_sql, ConnectionUrl @pytest.fixture(scope="module") # type: ignore @@ -446,5 +446,5 @@ def test_oracle_round_function(oracle_url: str) -> None: @pytest.mark.skipif( not os.environ.get("ORACLE_URL"), reason="Test oracle only when `ORACLE_URL` is set" ) -def test_connection(oracle_url: str) -> None: - test_oracle_round_function(Connection(oracle_url)) \ No newline at end of file +def test_connection_url(oracle_url: str) -> None: + test_oracle_round_function(ConnectionUrl(oracle_url)) \ No newline at end of file diff --git a/connectorx-python/connectorx/tests/test_redshift.py b/connectorx-python/connectorx/tests/test_redshift.py index 35ade1b60..97f4cb814 100644 --- a/connectorx-python/connectorx/tests/test_redshift.py +++ b/connectorx-python/connectorx/tests/test_redshift.py @@ -5,7 +5,7 @@ import pytest from pandas.testing import assert_frame_equal -from .. import read_sql, Connection +from .. import read_sql, ConnectionUrl @pytest.fixture(scope="module") # type: ignore @@ -140,5 +140,5 @@ def test_read_sql_on_utf8(redshift_url: str) -> None: not os.environ.get("REDSHIFT_URL"), reason="Do not test Redshift unless `REDSHIFT_URL` is set", ) -def test_connection(redshift_url: str) -> None: - test_read_sql_on_utf8(Connection(redshift_url)) +def test_connection_url(redshift_url: str) -> None: + test_read_sql_on_utf8(ConnectionUrl(redshift_url)) diff --git a/connectorx-python/connectorx/tests/test_sqlite.py b/connectorx-python/connectorx/tests/test_sqlite.py index 394b1837a..2456a4d2d 100644 --- a/connectorx-python/connectorx/tests/test_sqlite.py +++ b/connectorx-python/connectorx/tests/test_sqlite.py @@ -5,7 +5,7 @@ import pytest from pandas.testing import assert_frame_equal -from .. import read_sql, Connection +from .. import read_sql, ConnectionUrl @pytest.fixture(scope="module") # type: ignore @@ -392,5 +392,5 @@ def test_sqlite_cte(sqlite_db: str) -> None: assert_frame_equal(df, expected, check_names=True) -def test_connection(sqlite_db: str) -> None: - test_sqlite_cte(Connection(sqlite_db)) +def test_connection_url(sqlite_db: str) -> None: + test_sqlite_cte(ConnectionUrl(sqlite_db))