More complete sync table example
This commit is contained in:
parent
9f414938ba
commit
f2dae651b3
@ -22,14 +22,28 @@ Import some data using COPY FROM into a temporary table, then synchronize a tabl
|
|||||||
finally delete the temporary table. This could be used import and update some data periodically while
|
finally delete the temporary table. This could be used import and update some data periodically while
|
||||||
allowing to add columns to the data that will be preserved across updates.
|
allowing to add columns to the data that will be preserved across updates.
|
||||||
|
|
||||||
|
|
||||||
```sql
|
```sql
|
||||||
CREATE tmp_pois(cartodb_id int, name text, type text, longitude double precision, latitude double precision);
|
CREATE tmp_pois(cartodb_id int, name text, type text, longitude double precision, latitude double precision, rank int);
|
||||||
COPY tmp_pois FROM '/tmp/pois.csv';
|
COPY tmp_pois FROM '/tmp/pois.csv';
|
||||||
SELECT CDB_SyncTable('tmp_pois', 'public', 'pois');
|
SELECT CDB_SyncTable('tmp_pois', 'public', 'pois');
|
||||||
DROP TABLE tmp_pois;
|
DROP TABLE tmp_pois;
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Now we could perform some changes to the `pois` to maintain our own ranking:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
UPDATE pois SET rank = random()*4 + 1;
|
||||||
|
```
|
||||||
|
|
||||||
|
Then, if the source were updated at `/tmp/pois.csv` we could synchronize with it while maintaining our `rank` values with:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
CREATE tmp_pois(cartodb_id int, name text, type text, longitude double precision, latitude double precision, rank int);
|
||||||
|
COPY tmp_pois FROM '/tmp/pois.csv';
|
||||||
|
SELECT CDB_SyncTable('tmp_pois', 'public', 'pois', '{rank}');
|
||||||
|
DROP TABLE tmp_pois;
|
||||||
|
```
|
||||||
|
|
||||||
#### Arguments
|
#### Arguments
|
||||||
|
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user