diff --git a/examples/local_cache.py b/examples/local_cache.py index 5fbd3106..38af6a67 100644 --- a/examples/local_cache.py +++ b/examples/local_cache.py @@ -2,13 +2,8 @@ import letsql as ls -pg = ls.postgres.connect( - # FIXME: use dyndns to point examples.letsql.com to the gcp sql host - host="34.135.241.141", - user="letsql", - password="letsql", - database="letsql", -) + +pg = ls.postgres.connect_examples() con = ls.connect() # empty connection storage = ls.common.caching.ParquetCacheStorage( source=con, diff --git a/examples/multi_engine.py b/examples/multi_engine.py index 1757efb9..642be255 100644 --- a/examples/multi_engine.py +++ b/examples/multi_engine.py @@ -1,18 +1,9 @@ -import ibis - import letsql as ls con = ls.connect() # empty connection - -pg = ls.postgres.connect( - # FIXME: use dyndns to point examples.letsql.com to the gcp sql host - host="34.135.241.141", - user="letsql", - password="letsql", - database="letsql", -) -db = ibis.duckdb.connect() +pg = ls.postgres.connect_examples() +db = ls.duckdb.connect() batting = pg.table("batting").pipe(con.register, table_name="batting") diff --git a/python/letsql/backends/postgres/__init__.py b/python/letsql/backends/postgres/__init__.py index 227375b2..71577650 100644 --- a/python/letsql/backends/postgres/__init__.py +++ b/python/letsql/backends/postgres/__init__.py @@ -19,6 +19,23 @@ class Backend(IbisPostgresBackend): + _top_level_methods = ("connect_examples", "connect_env") + + @classmethod + def connect_env(cls, **kwargs): + from letsql.common.utils.postgres_utils import make_connection + + return make_connection(**kwargs) + + @classmethod + def connect_examples(cls): + return cls().connect( + host="examples.letsql.com", + user="letsql", + password="letsql", + database="letsql", + ) + @staticmethod def _register_and_transform_cache_tables(expr): """This function will sequentially execute any cache node that is not already cached""" diff --git a/python/letsql/backends/snowflake/__init__.py b/python/letsql/backends/snowflake/__init__.py index 8ea48a81..b29fe6e7 100644 --- a/python/letsql/backends/snowflake/__init__.py +++ b/python/letsql/backends/snowflake/__init__.py @@ -10,6 +10,14 @@ class Backend(IbisSnowflakeBackend): + _top_level_methods = ("connect_env",) + + @classmethod + def connect_env(cls, database="SNOWFLAKE_SAMPLE_DATA", schema="TPCH_SF1", **kwargs): + from letsql.common.utils.snowflake_utils import make_connection + + return make_connection(database=database, schema=schema, **kwargs) + @staticmethod def _register_and_transform_cache_tables(expr): """This function will sequentially execute any cache node that is not already cached"""