Last active
August 7, 2023 18:07
-
-
Save cpcloud/9c24b8dbc3a4a85a813c08f8063713d4 to your computer and use it in GitHub Desktop.
adbc vs sfc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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