473,385 Members | 1,400 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

database query - logic question

Thanks for anyone who takes the time to read this. If I posted to the
wrong list, I apologize and you can disregard.

I need help with a script to pull data from a postgres database. I'm ok
with the database connection just not sure how to parse the data to get
the results I need.

I'm running Python 2.4.4. For what it's worth, once I can get my logic
correct I'll be publishing the reports mentioned below via zope for web
clients.

Here is a small sample of the records in the table:

name date time status
machine1 01/01/2008 13:00:00 system ok
machine1 01/01/2008 13:05:00 system ok
machine1 01/01/2008 13:10:00 status1
machine1 01/01/2008 13:10:30 status1
machine1 01/01/2008 13:11:00 system ok
machine1 01/01/2008 13:16:30 status2
machine1 01/01/2008 13:17:00 status2
machine1 01/01/2008 13:17:30 status2
machine1 01/01/2008 13:18:00 status2
machine1 01/01/2008 13:18:30 status2
machine1 01/01/2008 13:19:00 system ok
machine1 01/01/2008 13:24:00 status2
machine1 01/01/2008 13:24:30 status2
machine1 01/01/2008 13:25:00 system ok

I need to report from this data.
The detail report needs to be something like:
machine1 01/01/2008 13:10:00 status1 00:01:30
machine1 01/01/2008 13:16:30 status2 00:02:30
machine1 01/01/2008 13:24:00 status2 00:01:00

and the summary needs to be
machine1 01/01/2008 total 'status1' time = 00:01:30
machine1 01/01/2008 total 'status2' time = 00:03:30
_____
machine1 01/01/2008 total 'non-OK' time = 00:05:00 #this is the
sum of status1 and status2 times

The 'machine1' system is periodically checked and the system status is
written to the database table with the machinename/date/time/status.
Everything that isn't a 'system ok' status is bad. For me to determine
the amount of time a machine was in a bad status I'm taking the first
time a machine has a 'system ok' status after a bad status and
subtracting from that time the time that a machine first went into that
bad status. From my table above:

machine1 went into 'status2' status at 13:16:30 and came out of
'status2' to a 'system ok' status at 13:19:00. So the downtime would be
13:19:00 - 13:16:30 = 00:02:30

I'm not sure how to query when a 'bad' status is found to find the next
'good' status and calculate based on the times. Essentially, I need
help creating the reports mentioned above. Your questions may also help
clarify my fuzzy description.

Thanks for any help. Reply with questions.

Israel
Jan 2 '08 #1
0 1052

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Stefanos | last post by:
Hi everybody, I need some help on calculated values in my database design. I'm creating an accounting / business management application with the usual modules like A/R, A/P, Inventory, etc. ...
3
by: Stefanos | last post by:
Hi everybody, I need some help on calculated values in my database design. I'm creating an accounting / business management application with the usual modules like A/R, A/P, Inventory, etc. ...
5
by: William Wisnieski | last post by:
Hello Everyone, I'm really stuck on how to design this application, so I thought I'd see if anyone had any general ideas on how to proceed. I'd say I'm an intermediate level Access developer. ...
7
by: bhipwell via AccessMonster.com | last post by:
Hello, I have developed an employee benefits database that currently contains over 3000 employees and 70+ companies. Having started the database as a really simple solution for our clients, the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.