Skip to content

Instantly share code, notes, and snippets.

@cpcloud
Last active August 7, 2023 18:07
Show Gist options
  • Save cpcloud/9c24b8dbc3a4a85a813c08f8063713d4 to your computer and use it in GitHub Desktop.
Save cpcloud/9c24b8dbc3a4a85a813c08f8063713d4 to your computer and use it in GitHub Desktop.
adbc vs sfc
import os
import adbc_driver_manager as adm
import adbc_driver_manager.dbapi
import snowflake.connector as sfc
def adbc():
with adm.dbapi.connect(
driver="adbc_driver_snowflake",
db_kwargs={
"uri": os.environ["SNOWFLAKE_URL"][len("snowflake://") :],
},
) as con:
with con.cursor() as cur:
cur.execute(
'SELECT * /* adbc */ FROM "SNOWFLAKE_SAMPLE_DATA".TPCH_SF1.LINEITEM'
)
result = cur.fetch_arrow_table()
print(len(result))
def scp():
with sfc.connect(
user=os.environ["SNOWSQL_USER"],
password=os.environ["SNOWSQL_PWD"],
account=os.environ["SNOWSQL_ACCOUNT"],
database=os.environ["SNOWSQL_DATABASE"],
schema=os.environ["SNOWSQL_SCHEMA"],
warehouse=os.environ["SNOWSQL_WAREHOUSE"],
) as con:
with con.cursor() as cur:
cur.execute(
'SELECT * /* snowflake-connector-python */ FROM "SNOWFLAKE_SAMPLE_DATA".TPCH_SF1.LINEITEM'
)
result = cur.fetch_arrow_all()
print(len(result))
if __name__ == "__main__":
"""Uncomment one of the calls."""
# adbc()
# scp()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment