4

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?

  • 1
    Not easily but we are working on it: github.com/CartoDB/cartodb/issues/909 – javisantana Oct 31 '14 at 10:01
  • Hi Jake, as Javi Santana mentioned above, the fix is already deployed. If you are interested in betatesting this, we could activate it for your account. Just let us know! – iriberri Nov 6 '14 at 14:07
  • @iriberri I would love to beta test it! My account is 'safedev' – Jake Molnar Nov 7 '14 at 1:49
  • It's already activated @JakeMolnar :-) – iriberri Nov 28 '14 at 10:49
  • @iriberri Awesome! :) – Jake Molnar Dec 1 '14 at 18:27
4

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');
  • 1
    Phew, I thought I was going crazy, cdb_cartodbfytable is very useful. – John Powell Mar 22 '15 at 10:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.