I have a time series database with just three columns. The first column is for the id, the second is for the time stamps, and the third column is for the output of the iOT. I am running the griddb python client on my Ubuntu machine. I need to get the most recent records from the database. The most recent records should be the ones just added on the day the query is run. Whether it’s an SQL query or a function, I just need a way to make it work. Here is how I stored the timeseries database in my GridDB container and an overview of the database.
python
##...
factory = griddb.StoreFactory.get_instance()
## Initializing the container
try:
gridstore = factory.get_store(host="127.0.0.1",
port=59111,
cluster_name="cluster_one",
username="admin",
password="")
conInfo = griddb.ContainerInfo("iOT_Project",
[["id", griddb.Type.INTEGER],
["time_stamp", griddb.Type.TIMESTAMP],
["output", griddb.Type.FLOAT]],
griddb.ContainerType.COLLECTION, True)
container = gridstore.put_container(conInfo)
## Reading the database with pandas
data = pd.read_csv("database.csv")
## Adding the database to the container
for i in range(len(data)):
ret = container.put(data.iloc[i, :])
print("Data added successfully")
except Exception as e:
print("Error: ", e)
iot_database
id | time_stamp | output |
---|---|---|
232 | 01/01/2019 11:20 | 85309.52 |
233 | 02/01/2019 12:52 | 6398.54 |
234 | 03/01/2019 23:45 | 97583.63 |
235 | 04/01/2019 22:21 | 86533.11 |
236 | 05/01/2019 13:42 | 12421.35 |