Comments (3)
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.
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.
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)
- "Line contains NUL" Exception after editing and saving a TinyFlux CSV in Excel HOT 5
- CSVStorage append blank lines on Windows HOT 1
- Field values of 0.0 are serialized to the DB as "_none" HOT 1
- Improve typing using mypy strict mode HOT 1
- Add ability to remove individual tags and fields from Points HOT 5
- Updating a Point with CSVStorage throws a TypeError
- Make package PEP 561 compliant HOT 1
- Compact storage with shorter tag and field key prefixes HOT 4
- Empty string tag values are read from storage as "_none" HOT 1
- Tag and Field keys should not be able to be removed in update callables
- Modifying the reference of a Point's tags or fields when using MemoryStorage HOT 2
- Data synchronisation from TinyFlux to InfluxDB or other HOT 1
- Python 3.12 support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tinyflux.