--- title: "Python Client" slug: "dataquery-python-client-vpc" updated: 2026-09-17T09:17:40Z published: 2026-09-17T09:17:40Z canonical: "guide.ncloud-docs.com/dataquery-python-client-vpc" --- > ## Documentation Index > Fetch the complete documentation index at: https://guide.ncloud-docs.com/llms.txt > Use this file to discover all available pages before exploring further. # Python Client Available in VPC It describes how to use Python Client provided by Data Query. ## Preparations Python 3.9 or later must be installed in the environment where you will be using Python Client. ## How to use It describes how to use Data Query Python Client. ### 1. Install package Install the [ncp-dataquery](https://pypi.org/project/ncp-dataquery/) package available on [PyPI.org](https://pypi.org). ``` # [required] Install ncp-dataquery package. pip install ncp-dataquery # [optional] If you integrate Data Query in sqlalchemy format, install the relevant package. pip install sqlalchemy ``` ### 2. Python Client integration examples #### Authentication method The NCP IAM authentication methods are supported using the `NcpIamAuthentication` class. You must enter your AccessKey and SecretKey. #### Submit queries and view results Write the code to submit the query and view the results. Example: ``` # DBAPI from ncp_dataquery.dbapi import connect from ncp_dataquery.auth import NcpIamAuthentication conn = connect( host="", port=443, auth=NcpIamAuthentication("", ""), http_scheme="https", reuse_query_result=True, # optional, default=False reuse_query_max_age=5, # optional, default=60, range=1~10080 (unit: minute) ) cur = conn.cursor() cur.execute("SELECT * FROM public_data.korea_national_railway.subway_seoul_capital_area LIMIT 10") rows = cur.fetchall() for row in rows: print(" ".join(row)) ``` ``` # SQLAlchemy from sqlalchemy import create_engine, text from ncp_dataquery.auth import NcpIamAuthentication engine = create_engine( "trino://:443/", connect_args={ "auth": NcpIamAuthentication("", ""), "http_scheme": "https", "reuse_query_result": True, # optional, default=False "reuse_query_max_age": 5, # optional, default=60, range=1~10080 (unit: minute) } ) with engine.connect() as conn: result = conn.execute(text("SELECT * FROM public_data.korea_national_railway.subway_seoul_capital_area LIMIT 10")) for row in result: print(f"{row}") ``` ``` // Result examples Daehwa, Line 3 operated by Korail 126.747756 37.675883 Daegok, Line 3 operated by Korail 126.811025 37.631629 Hwajeong, Line 3 operated by Korail 126.832503 37.637837 Wonheung, Line 3 operated by Korail 126.873239 37.650709 Juyeop, Line 3 operated by Korail 126.761232 37.670138 Jeongbalsan, Line 3 operated by Korail 126.773254 37.659709 Madu, Line 3 operated by Korail 126.777641 126.777641 Baekseok, Line 3 operated by Korail 126.788109 37.642973 Wondang, Line 3 operated by Korail 126.842891 37.653103 Samsong, Line 3 operated by Korail 126.895559 37.653096 ``` #### Available options - DBAPI: enter it as the argument value of `connect()`. - SQLAlchemy: enter is as the connect_args argument value of `create_engine()`. | Option name | Data type | Input values | Required | Note | | --- | --- | --- | --- | --- | | server | String | Data Query Endpoint | Y | For more information, see Data Query Service Endpoint by Region. | | reuse_query_result | Boolean | `true` or `false` | N | * default : `false` | | reuse_query_max_age | Integer | `1` ~ `10,080` | N | * default : `60` * Used only if the value of reuse-query-result is `true`. (Unit: time) | **Data Query Service Endpoint by Region** Currently, only the KR Region is available, with more Regions to be provided later. | Region | Endpoint | | --- | --- | | KR | kr.dataquery.naverncp.com | Note dataquery-python-client is provided based on trino-python-client. For more information beyond the options above, see [Trino documentation](https://github.com/trinodb/trino-python-client/tree/0.333.0).