This guide covers directly connecting Terrene to your database. It is not something we recommend but you can still do it. All the code in this guide should be run in a reducer.
Terrene supports SQLAlchemy outside of the box. To connect your database, please review their guide on creating an engine. In this example, we will connect to a Postgres database.
from sqlalchemy import create_engineengine = create_engine('postgresql+psycopg2://scott:[email protected]:5432/mydatabase')
Please make sure your database is allowing connections from your instance's IP address. To find out the IP address of your instance, please contact [email protected]
content.to_sql("name_of_sql_table", con=engine, if_exists='replace')
This code will override the existing data if table names collide.
After your code is complete, please create a custom code reducer and put the code in there. Then click on the settings icon on the top right corner
Then click on the "Convert to Atomic" button in the settings.
In supported data types, please select all options.
Finally, rename your custom code reducer to "Export to Database".
Then go to a TFrame you want to export, right click on any column, and then click on the "Export to Database".