I have been able to create tables that conform to the CartoDB style by the following method:
Create empty table [table name], no columns via SQL API
SELECT CDB_Cartodbyfy([table name]) via SQL API
Insert [table name] and current time into CDB_TableMetadata
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?
-
1Not easily but we are working on it: github.com/CartoDB/cartodb/issues/909javisantana– javisantana2014年10月31日 10:01:32 +00:00Commented 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!iriberri– iriberri2014年11月06日 14:07:34 +00:00Commented Nov 6, 2014 at 14:07
-
@iriberri I would love to beta test it! My account is 'safedev'Jake Molnar– Jake Molnar2014年11月07日 01:49:54 +00:00Commented Nov 7, 2014 at 1:49
-
It's already activated @JakeMolnar :-)iriberri– iriberri2014年11月28日 10:49:18 +00:00Commented Nov 28, 2014 at 10:49
-
@iriberri Awesome! :)Jake Molnar– Jake Molnar2014年12月01日 18:27:08 +00:00Commented Dec 1, 2014 at 18:27
1 Answer 1
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');
-
1Phew, I thought I was going crazy, cdb_cartodbfytable is very useful.John Powell– John Powell2015年03月22日 10:37:33 +00:00Commented Mar 22, 2015 at 10:37