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?

asked Oct 30, 2014 at 22:48
5
  • 1
    Not easily but we are working on it: github.com/CartoDB/cartodb/issues/909 Commented Oct 31, 2014 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! Commented Nov 6, 2014 at 14:07
  • @iriberri I would love to beta test it! My account is 'safedev' Commented Nov 7, 2014 at 1:49
  • It's already activated @JakeMolnar :-) Commented Nov 28, 2014 at 10:49
  • @iriberri Awesome! :) Commented Dec 1, 2014 at 18:27

1 Answer 1

5

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');
answered Dec 10, 2014 at 17:48
1
  • 1
    Phew, I thought I was going crazy, cdb_cartodbfytable is very useful. Commented Mar 22, 2015 at 10:37

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.