-
-
Save drorata/0e311961a81057863d5e4a122f2058d9 to your computer and use it in GitHub Desktop.
Basic querying example
This file contains 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
HIVE_HOST=my.location.com | |
HIVE_USERNAME=user.name | |
HIVE_PASSWORD=my_passWord |
This file contains 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
name: my_env | |
channels: | |
- conda-forge | |
dependencies: | |
- pip | |
- ipykernel | |
- "pandas<1.1" | |
- python-dotenv | |
- pip: | |
- thrift-sasl~=0.4.2 | |
- impyla~=0.16 |
This file contains 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 | |
from impala.dbapi import connect | |
from dotenv import load_dotenv | |
import pandas as pd | |
load_dotenv(override=True) | |
conn = connect( | |
host=os.getenv("HIVE_HOST"), | |
port=21050, | |
auth_mechanism='PLAIN', | |
use_ssl=True, | |
user=os.getenv("HIVE_USERNAME"), | |
password=os.getenv("HIVE_PASSWORD"), | |
) | |
cursor = conn.cursor() | |
with open("my_query.sql", "r") as f: | |
query = " ".join(f.readlines()) | |
df = pd.read_sql( | |
query, | |
conn | |
) | |
print(df) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment