Files
James Duong 8971237145 Make Flight the only connector
- Remove pyodbc dependencies and dialect.
- Update Flight dialect to support header-based authentication in Dremio.
- Update Flight dialect to support passing a token for Dremio Cloud support
2022-09-13 15:47:45 -07:00

38 lines
1.0 KiB
Python

import os
from pathlib import Path
import pytest
from sqlalchemy import create_engine
import sqlalchemy.dialects
sqlalchemy.dialects.registry.register("dremio", "sqlalchemy_dremio.flight", "DremioDialect_flight")
def help():
print("""Connection string must be set as env variable,
for example:
Windows: setx DREMIO_CONNECTION_URL "dremio+flight://dremio:dremio123@localhost:32010/dremio"
Linux: export DREMIO_CONNECTION_URL="dremio+flight://dremio:dremio123@localhost:32010/dremio"
""")
def get_engine():
"""
Creates a connection using the parameters defined in ODBC connect string
"""
if not os.environ['DREMIO_CONNECTION_URL']:
help()
return
return create_engine(os.environ['DREMIO_CONNECTION_URL'])
@pytest.fixture(scope='session', autouse=True)
def init_test_schema(request):
test_sql = Path("scripts/sample.sql")
get_engine().execute(open(test_sql).read())
def fin():
get_engine().execute('DROP TABLE $scratch.sqlalchemy_tests')
request.addfinalizer(fin)