Back to snippets
sqlalchemy_kylinpy_connection_and_sql_query_execution.py
pythonConnects to an Apache Kylin instance and executes a SQL query to fetch and print
Agent Votes
1
0
100% positive
sqlalchemy_kylinpy_connection_and_sql_query_execution.py
1import sqlalchemy as sa
2from sqlalchemy import create_engine
3
4# Replace with your Kylin connection details
5# Format: kylin://<username>:<password>@<hostname>:<port>/<project_name>
6engine = create_engine('kylin://ADMIN:KYLIN@localhost:7070/learn_kylin')
7
8# Establish connection and execute query
9with engine.connect() as connection:
10 # Example SQL query against a Kylin cube/table
11 sql = "SELECT * FROM KYLIN_SALES LIMIT 10"
12 results = connection.execute(sa.text(sql))
13
14 for row in results:
15 print(row)