I have been working with AWS Athena for a while and need to do create a backup and version control of the views. I’m trying to build an automation for the backup to run daily and get all the views.
I tried to find a way to copy all the views created in Athena using boto3, but I couldn’t find a way to do that. With Dbeaver I can see and export the views SQL script but from what I’ve seen only one at a time which not serve the goal.
I’m open for any way.
I try to find answer to my question in boto3 documentation and Dbeaver documentation. read thread on stack over flow and some google search did not took me so far.
2
Answers
Have you tried using get_query_results in boto3? get_query_results
Views and Tables are stored in the AWS Glue Data Catalog.
You can Query the AWS Glue Data Catalog – Amazon Athena to obtain information about tables, partitions, columns, etc.
However, if you want to obtain the DDL that was used to create the views, you will probably need to use
SHOW CREATE TABLE [db_name.]table_name
: