--
Adrian Klaver
[EMAIL PROTECTED]

 -------------- Original message ----------------------
From: "shawn bright" <[EMAIL PROTECTED]>
> 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 <[EMAIL PROTECTED]> wrote:
> >
> >  -------------- Original message ----------------------
> > From: "shawn bright" <[EMAIL PROTECTED]>
> > > 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
> > [EMAIL PROTECTED]

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.

--- Begin Message --- 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 <[EMAIL PROTECTED]> wrote:
 -------------- Original message ----------------------
From: "shawn bright" <[EMAIL PROTECTED] >
> 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
[EMAIL PROTECTED]



---------- Forwarded message ----------
From: "shawn bright" < [EMAIL PROTECTED]>
To: storm <[email protected]>
Date: Tue, 7 Aug 2007 16:30:26 +0000
Subject: [storm] another question regarding inserts
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






--
storm mailing list
[email protected]
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/storm



--- End Message ---
-- 
storm mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/storm

Reply via email to