awswrangler.athena.create_prepared_statement¶
- awswrangler.athena.create_prepared_statement(sql: str, statement_name: str, workgroup: str = 'primary', mode: Literal['update', 'error'] = 'update', boto3_session: Session | None = None) None ¶
Create a SQL statement with the name statement_name to be run at a later time. The statement can include parameters represented by question marks.
https://docs.aws.amazon.com/athena/latest/ug/sql-prepare.html
Note
This function has arguments which can be configured globally through wr.config or environment variables:
workgroup
Check out the Global Configurations Tutorial for details.
- Parameters:
sql (str) – The query string for the prepared statement.
statement_name (str) – The name of the prepared statement.
workgroup (str) – The name of the workgroup to which the prepared statement belongs. Primary by default.
mode (str) –
Determines the behaviour if the prepared statement already exists:
update
- updates statement if already existserror
- throws an error if table exists
boto3_session (boto3.Session(), optional) – Boto3 Session. The default boto3 session will be used if boto3_session receive None.
Examples
>>> import awswrangler as wr >>> wr.athena.create_prepared_statement( ... sql="SELECT * FROM my_table WHERE name = ?", ... statement_name="statement", ... )