[gdal-dev] CartoDB driver fail because drop sequence sentence fails

Jorge Arevalo jorgearevalo at libregis.org
Mon Mar 10 10:38:03 PDT 2014


Hello,

On Thu, Mar 6, 2014 at 8:05 PM, Even Rouault
<even.rouault at mines-paris.org> wrote:
> Le jeudi 06 mars 2014 18:45:50, Jorge Arevalo a écrit :
>> Hello,
>>
>> I'm trying to create a new table in CartoDB using the GDAL CartoDB
>> driver and Python bindings. I'm getting a HTTP 400 error.
>>
>> This is the source code:
>>
>> from osgeo import ogr
>> from osgeo import gdal
>>
>> gdal.SetConfigOption("CARTODB_API_KEY", MY_API_KEY)
>> drv = ogr.GetDriverByName("CartoDB")
>> cartodb_ds = drv.Open('cartodb:%s' % MY_ACCOUNT_NAME, update=1)
>> if cartodb_ds is None:
>>     print 'Cannot open CartoDB connection for writing'
>>
>> cartodb_layer = cartodb_ds.CreateLayer('my_layer',
>> geom_type=ogr.wkbMultiPolygon)
>>
>>
>> Activating debug, this is what the driver sends to CartoDB:
>>
>> q=CREATE TABLE "my_layer" ( cartodb_id SERIAL, the_geom
>> GEOMETRY(MULTIPOLYGON, 0), the_geom_webmercator GEOMETRY(MULTIPOLYGON,
>> 3857),PRIMARY KEY (cartodb_id) );DROP SEQUENCE IF EXISTS
>> "my_layer_cartodb_id_seq";CREATE SEQUENCE "my_layer_cartodb_id_seq"
>> START 1;ALTER TABLE my_layer ALTER COLUMN cartodb_id SET DEFAULT
>> nextval('my_layer_cartodb_id_seq')&api_key=1f1464a7f041a39568046b858af425ab
>> ab4fefc6
>>
>>
>> And the response error message (HTTP error 400):
>>
>> CARTODB: RunSQL Response:{"error":["cannot drop sequence
>> my_layer_cartodb_id_seq because other objects depend on it"]}
>
> Perhaps use DROP CASCADE intead of DROP ?
> Feel free to modify the driver.
>

I'm waiting until CartoDB team solves this issue:
https://github.com/CartoDB/cartodb/issues/115, because the tables
created via driver won't appear in the Dashboard, and I need them to
appear.

Thanks anyway!

>>
>> If I get rid of all the SQL after the create table sentence itself, it
>> works, and the table is created. I guess I could modify the driver to
>> avoid this, but I'd like to know if someone is using it and having
>> this problem.
>>
>> BTW, the tables created via SQL API don't appear in the CartoDB
>> dashboard, but this is a known issue (
>> https://github.com/CartoDB/cartodb/issues/115)
>>
>> Best regards,
>
> --
> Geospatial professional services
> http://even.rouault.free.fr/services.html



-- 
Jorge Arevalo
Freelance developer

http://about.me/jorgeas80


More information about the gdal-dev mailing list