Source code for pyathena.sqlalchemy.rest
# Copyright 2023 The PyAthena authors
#
# Licensed under the MIT License.
# See LICENSE or https://opensource.org/licenses/MIT.
#
# SPDX-License-Identifier: MIT
"""SQLAlchemy dialect for Athena that uses the default ``Cursor``."""
from typing import TYPE_CHECKING
from pyathena.sqlalchemy.base import AthenaDialect
from pyathena.util import override
if TYPE_CHECKING:
from types import ModuleType
[docs]
class AthenaRestDialect(AthenaDialect):
"""SQLAlchemy dialect for Amazon Athena using the standard REST API cursor.
This dialect uses the default Cursor implementation, which retrieves
query results via the GetQueryResults API. Results are returned as
Python tuples with type conversion handled by the default converter.
This is the standard dialect for general-purpose Athena access and is
suitable for most use cases where specialized result formats (Arrow,
pandas) are not required.
Connection URL Format:
``awsathena+rest://{access_key}:{secret_key}@athena.{region}.amazonaws.com/{schema}``
Example:
>>> from sqlalchemy import create_engine
>>> engine = create_engine(
... "awsathena+rest://:@athena.us-west-2.amazonaws.com/default"
... "?s3_staging_dir=s3://my-bucket/athena-results/"
... )
See Also:
:class:`~pyathena.cursor.Cursor`: The underlying cursor implementation.
:class:`~pyathena.sqlalchemy.base.AthenaDialect`: Base dialect class.
"""
driver = "rest"
supports_statement_cache = True
[docs]
@classmethod
@override
def import_dbapi(cls) -> "ModuleType":
return super().import_dbapi()