[storm] another question regarding inserts

shawn bright nephish at gmail.com
Tue Aug 7 21:33:19 BST 2007


ok
here is what i have for history
CREATE TABLE `history` (
  `id` int(11) NOT NULL auto_increment,
  `monitor` varchar(25) NOT NULL,
  `function` varchar(25) NOT NULL,
  `raw` float NOT NULL default '0',
  `value` varchar(10) NOT NULL default '0',
  `date_time` datetime NOT NULL default '0000-00-00 00:00:00',
  `s_date_time` datetime NOT NULL default '0000-00-00 00:00:00',
  `sid` varchar(20) default '0',
  `switch` varchar(20) default '0',
  PRIMARY KEY  (`id`),
  KEY `monitor` (`monitor`)
) ENGINE=MyISAM AUTO_INCREMENT=32268398 DEFAULT CHARSET=latin1
AUTO_INCREMENT=32268398 ;


and status_hits
CREATE TABLE `status_hits` (
  `id` int(11) NOT NULL auto_increment,
  `status_sensor_id` int(11) default NULL,
  `raw` int(11) default NULL,
  `value` varchar(10) default NULL,
  `date_time` datetime NOT NULL default '0000-00-00 00:00:00',
  `sensor_time` datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (`id`),
  KEY `sensor_id` (`status_sensor_id`,`date_time`),
  KEY `date_time` (`date_time`)
) ENGINE=MyISAM AUTO_INCREMENT=17061974 DEFAULT CHARSET=latin1
AUTO_INCREMENT=17061974 ;


And the classes

class StatusHit(Storm):
      __storm_table__ = "status_hits"
     id = Int(primary = True)
     status_sensor_id = Int()
     raw, value = Float(), Unicode()
     date_time = DateTime()
     sensor_time = DateTime()

 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()

hope this helps
and thanks for the attention for this.

shawn


On 8/7/07, Adrian Klaver <aklaver at comcast.net> wrote:
>
>
>
> --
> 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.
>
>
>
> ---------- Forwarded message ----------
> From: "shawn bright" <nephish at gmail.com>
> To: "Adrian Klaver" <aklaver at comcast.net>
> Date: Tue, 7 Aug 2007 19:20:29 +0000
> Subject: Re: [storm] another question regarding inserts
> 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
> >
> >
> >
> > ---------- Forwarded message ----------
> > From: "shawn bright" < nephish at gmail.com>
> > To: storm <storm at lists.canonical.com>
> > 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
> > storm at lists.canonical.com
> > Modify settings or unsubscribe at:
> > https://lists.ubuntu.com/mailman/listinfo/storm
> >
> >
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ubuntu.com/archives/storm/attachments/20070807/97012140/attachment-0001.htm 


More information about the storm mailing list