Get list of Measurements with Influx 2 - influxdb

I'm having trouble understanding how to use some InfluxDB 2 APIs from Python, using the influxdb-client-python library for InfluxDB 2
For example I would like to get a list of measurements in a bucket.
Official documentation (not Python) suggest this:
Use the schema.measurements() function to list measurements in a bucket.
import "influxdata/influxdb/schema"
schema.measurements(bucket: "example-bucket")

I have searched through the library's code to see if I could find something that does this. I might be wrong, but it appears that as of right now there's no interface for this functionality.
However, it is possible to do what you want by executing the following:
from influxdb_client import InfluxDBClient
address = "myaddress"
token = "mytoken"
org = "myorg"
client = InfluxDBClient(url=address, token=token, org=org)
qapi = client.query_api()
q = 'import "influxdata/influxdb/schema"\n\nschema.measurements(bucket: "example-bucket")'
tables = qapi.query(q)
for table in tables:
print(table)
for record in table.records:
print(record.values)
You will have to substitute any defined variables from this code sample with your own. Also, make sure that the bucket name in the query matches the bucket you want to query.
Finally, the token you use must have enough permissions to accomplish the task.

Related

Query tags/context labels of senses using JWKTL

I am working on a project where I need to deal with Wiktionary. For some entries, there are context labels/tags before its sense I want to query for, e.g. idiomatic, transitive like HERE. I am now trying to use JWKTL, to do the job. But it seems no api call supports the query.
Can anyone let me know how to get that information by JWKTL, or, is there any other tool can parse the Wiktionary dump .xml file while being able to access that labels/tags?
Thanks.
According to Dr. Christian. Meyer, there is currently no API on this.
I ended up with pattern matching in the original wiktionary .xml dump.

py2neo - updating existing node with new properties w/uniqueness constraint (merge_one)

I've been trying to figure out a way to adapt the merge_one functionality from py2neo v2 to v3. I read in a Google group that "The merge_one method no longer exists in v3 as you should be able to use merge in all cases instead." but I can't figure out how to easily use regular merge in v3.
I'm trying to recreate Nicole White's neo4j twitter example project with a small modification. She used merge_one. There are uniqueness constraints on (u:User) - u.username and (t:Tweet) - t.id. Her script always has the same properties for Tweet and User nodes, but I am making a case where sometimes I want to go back and add more properties to an existing node with merge. However I get the error
py2neo.database.status.ConstraintError: Node 178 already exists with label Tweet and property "id"=[***]
I understand this is because when I have for example a Tweet that already exists with just an id and then I try to do
tw_dict = {'id'=t['id'], 'text':t['text'], 'created':t['created_at'],
'rts':t['retweet_count'],
'favs':t['favorite_count'], 'lang':t['lang']}
tweet = Node("Tweet", **tw_dict)
graph.create(tweet)
merge is not finding the same tweet with all those properties and when it tries to create one is running into the uniqueness constraint on Tweet's id. It looks like the merge_one function would have solved this, but it's not available in v3. So instead I've implemented the following:
exists = graph.find_one("Tweet", "id", t['id'])
if exists:
exists['text'] = t['text']
exists['created'] = t['created_at']
exists['rts'] = t['retweet_count']
exists['favs'] = t['favorite_count']
exists['lang'] = t['lang']
else:
tw_dict = {'text':t['text'], 'created':t['created_at'],
'rts':t['retweet_count'],
'favs':t['favorite_count'], 'lang':t['lang']}
tweet = Node("Tweet", **tw_dict)
graph.create(tweet)
but this seems repetitive to me. Is there not an easier way in py2neo to do something like updating an existing node with new properties and still specifying a property with a unique constraint (in this case id)? I think in Cypher I would do a merge on just the id and then set on match or set on create but I don't see how to do that with py2neo. I also tried to find in the documentation something that would allow an update of properties from a dictionary with an existing node but can't.
py2neo v3 now has graph.merge(), which you can use to the same effect.
First find or create the node with graph.merge(), matching only on its unique property, then update its other non-unique properties with node.push(). You would've had to do the same thing with graph.merge_one(), just with a slightly different syntax.
from py2neo import Graph, Node
graph = Graph()
tweet = Node('Tweet', id=123)
graph.merge(tweet)
tweet['text'] = 'Hello World'
tweet.push()
I should update that twitter script to use py2neo v3; thanks for the reminder.
Two things;
1.)
tweet.push() has been deprecated. The docs suggest using graph.push(tweet).
2.)
I am having trouble to get this working with a transaction such as:
transaction = graph.begin()
transaction.merge(tweet)
transaction.graph.push(tweet)
transaction.commit()
Any suggestion on the difference between using graph.merge and transaction.merge?
To update for py2neo v5 - 2020, you may update multiple properties for an existing node from a dictionary.
from py2neo import NodeMatcher
tw_dict = {'text':t['text'],
'created':t['created_at'],
'rts':t['retweet_count'],
'favs':t['favorite_count'],
'lang':t['lang']}
tweet = matcher.match('Tweet', id=123).first()
if tweet:
tweet.update(**properties)
graph.push(tweet)

Rails 4 .dat import postgreSQL and ajax search

I want to implement a flight search system in Rails 4.
And I found this resource,
My questions are:
I've downloaded the airports.dat file and it contains chunks of data, do I need to import those data into psql? If yes, how?
If I just need the airport ID and name values, how do I selectively import them?
If I want to implement ajax load airport name just like the way expedia.com did, would it be buggy(slow loading time) if I use VPSs like Digitalocean?
Please advise me.
You can write a method that read line by line, and parse every line by the comma (","). Then you have enough information to insert to database.
For example:
flight1 = '507,"Heathrow","London","United Kingdom","LHR","EGLL",51.4775,-0.461389,83,0,"E","Europe/London"'
Then you can get the ID by call flight1.split(",")[0]
The speed of your search function is affected by your search algorithm and how do you implement the logic, and isn't affected by using a VPS.

How do I construct the cake when using Scalaxb to connect to a SOAP service?

I've read the documentation, but what I need to know is:
I'm not using a fictitious stock quote service (with an imaginary wsdl file). I'm using a different service with a different name.
Where, among the thousands and thousands of lines of code that have been generated, will I find the Scala trait(s) that I need to put together that correspond to this line in the documentation's example:
val service = (new stockquote.StockQuoteSoap12Bindings with scalaxb.SoapClients with scalaxb.DispatchHttpClients {}).service
Now, you might be thinking "Why not just search for Soap12Bindings in the generated code"? Good idea - but that turns up 0 results.
The example in the documentation is outdated, or too specific. (The documentation is also internally inconsistent and inconsistent with the actual filenames output with scalaxb.)
First, search for SoapBindings instead of Soap12Bindings to find the service-specific trait (the first trait).
Then, instead of scalaxb.SoapClients, use scalaxb.Soap11Clients.

How to pass multiple Flags into the IMAP.?

I am working on MailClient and I want to set Multipal Flags for Eg. SEEN, UNSEEN so how I can set in C#,
I had pass this command like this but it will give me error. like BAD command.
so the my command like this.
byte[] commandBytes = System.Text.Encoding.ASCII.GetBytes((#"$ UID SEARCH UNSEEN \SEEN" + "\r\n"));
Thanks..
Don't use backslash, this is the correct request:
A000 UID SEARCH SEEN UNSEEN
Are you sure you want write you own IMAP client from scrach? There are some opensource libraries, as well as paid ones (My Mail.dll IMAP component for example).

Resources