Programmatically registering a datasource and entity key attributes

Two (related) questions:

  1. Does anyone know if its possible to programmatically register a data source?

  2. Programmatically define entity keys and their relationships?

Ideally I’d like to be able to do both.

1 Like

I don’t know if I understood it right. If you want something that could create tables, columns and relationship without writing in the database sintaxe or dbeaver, you could use Django.models
https://docs.djangoproject.com/en/2.2/topics/db/models/

Let me know it’s what you were looking for. Or provides more detail to see if I have the knowledge to help you.

Hi @Frederico I have a number of database(s) with tables already created, we dont use FK to constrain the relations. We would like to avoid having to manually add the source etc. using the Admin module to add each database and define the relationships leveraged by metabase. I suspect if I populate the “metabase_database”, “metabase_table” and “metabase_field” tables, then rely on the automated metabase sync process to then update and populate the other dependancies…

1 Like

Hi @brianwilson
Yes, use the force API:
https://github.com/metabase/metabase/wiki/Using-the-REST-API
https://github.com/metabase/metabase/blob/master/docs/api-documentation.md
It is possible to manually mess around in the metadata database, but it will likely end with something corrupted, so use the API.
And a really good learning way I’m using - just use Metabase regularly and open your browser console’s Network tab, since the Metabase interface is just making API calls for everything it does.

2 Likes