Athena SDK can save pandas DataFrames as assets out of the box:
The result will contain the asset_id
.
It can also save most plots objects which support IPython display protocol, for example:
You can set the parent_folder_id
to upload the file (or plot/data frame) to a specific folder.
To upload a file using the Athena SDK, you can use the athena.tools.save_asset()
method. This method accepts a file tuple containing the filename, file content as a BytesIO
object, and the MIME type.
Here’s an example of how to upload an Excel file:
In this example:
BytesIO
object.BytesIO
object, and the MIME type.athena.tools.save_asset()
with our file tuple.If you’re using FastAPI and want to upload files received from a client, you can use the UploadFile
object:
This endpoint will accept file uploads and forward them to the Athena API using the SDK.
Remember to handle exceptions and implement proper error checking in your production code.