Using python within query as a source

Hello - first post, set up Metabase this weekend on Elastic Beanstalk and everything is working great. Love it so far.

I’m wondering if there’s any way to use Python as a source for a chart in Metabase? Idea being I would have my SQL query embedded in Python so I could get the data, do some manipulations / math / forecasting, etc., in Python, and then pass the dataframe to Metabase for visualization.

Wondering if it’s somehow possible to have the python in Metabase, or if anyone else has developed a way possibly where you have your python script outside of Metabase that passes the dataframe to it?

Any help or thoughts would be greatly appreciated!

Hi @jbrooks
You would need to create an interface that Metabase can connect to. Current supported databases are:
https://www.metabase.com/docs/latest/faq/setup/which-databases-does-metabase-support.html
Otherwise you would need to create your own custom driver.

1 Like

Thanks @flamber. I guess what I could do is set up is set up a server somewhere that stores a python script that saves to a database, and have Metabase hit that database.

Question: I can SSH into my EC2 instance that’s running Metabase - would you recommend against hosting some python scripts, a database, and maybe even a Jupyter container on this EC2 instance? Just to save me from having to spin up another instance, and so it’s all in one place? I don’t know how updating Metabase works technically and if it just like wipes everything on the server when it updates.

Thank you!

@jbrooks Running on EC2 doesn’t tell me anything. But make sure that you’re not using H2 for the application database:
https://www.metabase.com/docs/latest/operations-guide/migrating-from-h2.html
Just like with any other piece of software - you can run them all in the same environment, or separate them in containers or different hosts - that depends on how you prefer to run things.