Code Monkey home page Code Monkey logo

Comments (3)

noeldum avatar noeldum commented on May 30, 2024

I found one way to do it with the index.latest_time function (which is with a tipo as lateset_time, I must have an older version)

Time = TimeQuery()
t = db.index.lateset_time
db.search(Time == t)

Let me know if there is a better way to it.

It could be nice to include the usage of latest_time in the doc.

from tinyflux.

citrusvanilla avatar citrusvanilla commented on May 30, 2024

The current index in tinyflux does not keep track of the order of what was recently inserted into the database. Even if this was supported, the index would be wiped of this information when the python process is stopped since the index is not persistent (like you will find in a db server).

Are you trying to get the latest timestamp associated with a Point? I suppose there is a case where you insert a Point that is way into the past when you manually specify the time to be in the past- do you want to retrieve this item? Or simply the item with the most-recent timestamp? To get the Point with the latest timestamp:

There is an API call for the Index actually that is used internally, if you want to access it directly as sort-of a hack, do this:

from tinyflux import TinyFlux, Point

# Your db.
db = TinyFlux("test.db")

# Make sure the index is valid.  It should be unless you turned indexing off yourself.
assert db.index._valid

# Here's the api call:
max_time = db.index.latest_time

print(max_time)

should print 2023-09-25 20:18:57.502769+00:00

I just saw your follow up and fixed the spelling bug. There is a new version, 0.4.1, with the spelling fixed. Here is the reference in the readme:

https://tinyflux.readthedocs.io/en/latest/tinyflux.html#tinyflux.index.Index.latest_time

from tinyflux.

noeldum avatar noeldum commented on May 30, 2024

Thank you. Yes it's the latest timestamp that I need. Not the latest inserted although in my particular application they are always the same. A plain write once recording db.

will go with the latest_time method then.

from tinyflux.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.