[storm] another question regarding inserts

Adrian Klaver aklaver at comcast.net
Tue Aug 7 21:05:02 BST 2007



--
Adrian Klaver
aklaver at comcast.net

 -------------- Original message ----------------------
From: "shawn bright" <nephish at gmail.com>
> Oh, yeah, sorry about the confusion there, the StatusHit is a different
> class that points to a different table in the database.
> 
> We have all these different types of sensors that report in. Status, Volts,
> Accumulators, Analog, etc...
> for every sensor type there is a table StatusSenso = status_sensors,
> VoltSensor = volt_sensors and so on ...
> 
> each type of sensor has its own history table to log the report history for
> each.
> so we have voltage_hits, status_hits, analog_hits, etc...
> 
> HistoryHit, is a class that represents everything.  Everthing that reports
> goes into a history table ( currently 1.7 GB )
> 
> so if a status_sensor reports, there is an update to StatusSensor, a new
> record in StatusHits, and a new record in history (HistoryHit).
> 
> thanks
> 
> 
> 
> On 8/7/07, Adrian Klaver <aklaver at comcast.net> wrote:
> >
> >  -------------- Original message ----------------------
> > From: "shawn bright" <nephish at gmail.com>
> > > hello again,
> > >
> > > i have a kinda different problem with and insert function i created.
> > >
> > > here is the class
> > > class HistoryHit(object):
> > >     __storm_table__ = "history"
> > >     id = Int(primary = True)
> > >     monitor, function, value = Unicode(), Unicode(), Unicode()
> > >     raw = Float()
> > >     date_time, s_date_time = DateTime(), DateTime()
> > >     sid, switch = Unicode(), Unicode()
> > >
> > > here is the function:
> > > def make_history(obj, function, s_time = 'none', sid='none',
> > switch='none'):
> > >     print '\n\n make history'
> > >     print 'found object %s' % obj.monitor
> > >     print 'found raw = %s' % obj.last_raw
> > >     print 'type of raw = %s' % type(obj.last_raw)
> > >     print 'found value = %s ' % obj.last_value
> > >     store = Store.of(obj)
> > >     hit = HistoryHit()
> > >     hit.monitor = obj.monitor
> > >     hit.raw = Float(obj.last_raw)
> > >     hit.value = unicode(obj.last_value)
> > >     hit.function =  unicode(function)
> > >     if s_time == 'none': hit.s_date_time = datetime.datetime.now()
> > >     hit.date_time = datetime.datetime.now()
> > >     hit.sid, hit.switch = unicode(sid), unicode(switch)
> > >     store.add(hit)
> > >
> > >
> > > the lines that call it:
> > > status_sensor.last_raw = raw
> > > status_sensor.last_value = value
> > > status_sensor.last_report = datetime.datetime.now()
> > > hit = StatusHit()
> > > hit.status_sensor_id = status_sensor.id
> > > hit.raw = raw
> > > hit.value = value
> > > hit.date_time = datetime.datetime.now()
> > > hit.sensor_time = sensor_time
> > > self.store.add(hit)
> > > make_history(status_sensor, 'orbcomm status', s_time = sensor_time)
> > >
> > > INSERT INTO history (date_time, function, monitor, sid, switch, value)
> > > VALUES (%s, %s, %s, %s, %s, %s) (datetime.datetime(2007, 8, 7, 11, 31,
> > 8,
> > > 634691), u'orbcomm status', u'RNKE734X1', u'none', u'none', u'r')
> > > SELECT history.id, history.s_date_time FROM history WHERE history.id =
> > > 32246084 ()
> > >
> > >
> > >  why isn't raw added to the insert into ?  the rest of the info is
> > there,
> > > but the raw is missing, it does show up in the terminal from the print
> > > statement though.
> > >  why is there a select on history after the insert ? Nothing else really
> > > ever calls for it.
> > >
> > > thanks
> > >
> > > shawn
> >
> > One problem is that you are showing the class HistoryHit() but using the
> > class StatusHit() to do the insert. The make_history function is using
> > HistoryHit() so you are looking at the results coming from two different
> > classes.
> >
> >
> > --
> > Adrian Klaver
> > aklaver at comcast.net

I inadvertently replied to Shawn only in my original response. I am bringing this thread
back to the list. At this point I do not have an answer for why the raw value is not showing
up. It would be nice to see the schema for the History and StatusHit tables.

-------------- next part --------------
An embedded message was scrubbed...
From: "shawn bright" <nephish at gmail.com>
Subject: Re: [storm] another question regarding inserts
Date: Tue, 7 Aug 2007 19:20:29 +0000
Size: 9050
Url: https://lists.ubuntu.com/archives/storm/attachments/20070807/6733f698/attachment-0001.eml 


More information about the storm mailing list