[GIS] When we create a CartoDB table using SQL, is there a way to register it with the tables dashboard

carto

I have been able to create tables that conform to the CartoDB style by the following method:

  1. Create empty table [table name], no columns via SQL API

  2. SELECT CDB_Cartodbyfy([table name]) via SQL API

  3. Insert [table name] and current time into CDB_TableMetadata

  4. Add user columns and data via SQL API

I can even get the table to show up on the CartoDB tables dashboard, by creating an empty table and then renaming it to [table name]. However, what I really want is a way to make my programmatically-created tables appear on the dashboard without having to manually interact with the CartoDB web app.

I suspect I could make this happen by posting to the Imports API with table_name=[new table name]&table_copy=[table name]. However, using the table_copy parameter is forbidden, and I do not wish to violate that.

So, my question is this: Is there a way to accomplish what I want (programmatic registration of existing tables) without violating the rules of CartoDB's APIs?

Best Answer

basically this is the guide: https://github.com/CartoDB/cartodb/wiki/creating-tables-though-the-SQL-API

the important information:

lets create a table using SQL API:

create table test (whatever int);

at this point you will not able to see table test in the editor

select cdb_cartodbfytable('test');

Now if you go to your dashboard should appear (it takes some seconds to be available, so refresh after a bit if it's not there)

For people using multiuser account you need to include your username in cdb_cartodbfytable call:

select cdb_cartodbfytable('myuser', 'test');
Related Question