fixed url variable in full script example
parent
0c0a16c6db
commit
6789f6a29c
|
@ -54,11 +54,11 @@ import (
|
||||||
Next, define variables for your InfluxDB [bucket](/v2.0/organizations/buckets/), [organization](/v2.0/organizations/), and [token](/v2.0/security/tokens/).
|
Next, define variables for your InfluxDB [bucket](/v2.0/organizations/buckets/), [organization](/v2.0/organizations/), and [token](/v2.0/security/tokens/).
|
||||||
|
|
||||||
```go
|
```go
|
||||||
bucket = "<my-bucket>"
|
bucket := "<my-bucket>"
|
||||||
org = "<my-org>"
|
org := "<my-org>"
|
||||||
token = "<my-token>"
|
token := "<my-token>"
|
||||||
//variable to store the url of your local or InfluxDB Cloud instance
|
//variable to store the url of your local or InfluxDB Cloud instance
|
||||||
url = "<http://localhost:9999>"
|
url := "<http://localhost:9999>"
|
||||||
``
|
``
|
||||||
|
|
||||||
To write data, create the the InfluxDB Go Client and pass in our named parameters: `url` and `token`.
|
To write data, create the the InfluxDB Go Client and pass in our named parameters: `url` and `token`.
|
||||||
|
@ -100,8 +100,10 @@ client.Close()
|
||||||
bucket := "<my-bucket>"
|
bucket := "<my-bucket>"
|
||||||
org := "<my-org>"
|
org := "<my-org>"
|
||||||
token := "<my-token>"
|
token := "<my-token>"
|
||||||
|
//variable to store the url of your local or InfluxDB Cloud instance
|
||||||
|
url := "<http://localhost:9999>"
|
||||||
// Create new client with default option for server url authenticate by token
|
// Create new client with default option for server url authenticate by token
|
||||||
client := influxdb2.NewClient("http://localhost:9999", token)
|
client := influxdb2.NewClient(url, token)
|
||||||
// User blocking write client for writes to desired bucket
|
// User blocking write client for writes to desired bucket
|
||||||
writeApi := client.WriteApiBlocking(org, bucket)
|
writeApi := client.WriteApiBlocking(org, bucket)
|
||||||
// Create point using full params constructor
|
// Create point using full params constructor
|
||||||
|
@ -171,9 +173,9 @@ The query client sends the Flux query to InfluxDB and returns the results as a F
|
||||||
```go
|
```go
|
||||||
func main() {
|
func main() {
|
||||||
// Create client
|
// Create client
|
||||||
client := influxdb2.NewClient("http://localhost:9999", "my-token")
|
client := influxdb2.NewClient(url, token)
|
||||||
// Get query client
|
// Get query client
|
||||||
queryApi := client.QueryApi("my-org")
|
queryApi := client.QueryApi(org)
|
||||||
// Get QueryTableResult
|
// Get QueryTableResult
|
||||||
result, err := queryApi.Query(context.Background(), `from(bucket:"my-bucket")|> range(start: -1h) |> filter(fn: (r) => r._measurement == "stat")`)
|
result, err := queryApi.Query(context.Background(), `from(bucket:"my-bucket")|> range(start: -1h) |> filter(fn: (r) => r._measurement == "stat")`)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
|
@ -86,9 +86,11 @@ from influxdb_client.client.write_api import SYNCHRONOUS
|
||||||
bucket = "<my-bucket>"
|
bucket = "<my-bucket>"
|
||||||
org = "<my-org>"
|
org = "<my-org>"
|
||||||
token = "<my-token>"
|
token = "<my-token>"
|
||||||
|
#variable to store the url of your local or InfluxDB Cloud instance
|
||||||
|
url="<http://localhost:9999>"
|
||||||
|
|
||||||
client = influxdb_client.InfluxDBClient(
|
client = influxdb_client.InfluxDBClient(
|
||||||
url="http://localhost:9999",
|
url=url,
|
||||||
token=token,
|
token=token,
|
||||||
org=org
|
org=org
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue