Skip to content

Latest commit

 

History

History

WriteDataInBatches

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

WriteDataInBatches

How to use Combine to prepare batches for write into InfluxDB

Prerequisites:

  • macOS 11+
  • Cloned examples:
    git clone [email protected]:influxdata/influxdb-client-swift.git
    cd Examples/WriteDataInBatches

Sources:

How to test:

  1. Start InfluxDB:
    docker run --rm \
      --name influxdb_v2 \
      --detach \
      --publish 8086:8086 \
      influxdb:latest
  2. Configure your username, password, organization, bucket and token:
    docker run --rm \
       --link influxdb_v2 \
       curlimages/curl -s -i -X POST http://influxdb_v2:8086/api/v2/setup \
          -H 'accept: application/json' \
          -d '{"username": "my-user", "password": "my-password", "org": "my-org", "bucket": "my-bucket", "token": "my-token"}'
  3. Write data by:
    swift run write-data-in-batches --bucket my-bucket --org my-org --token my-token --url http://localhost:8086

Expected output

Writing 500 items ...
 > success
Writing 500 items ...
 > success
Writing 500 items ...
 > success
Writing 500 items ...
 > success
Writing 500 items ...
 > success
Writing 500 items ...
 > success
Writing 500 items ...
 > success
Writing 452 items ...
 > success
Import finished!