ok, here is my new function:<br>def make_history(obj, function, s_time = 'none', sid='none', switch='none'):<br> print '\n\n make history'<br> print 'found object %s' % obj.monitor
<br> print 'found raw = %s' % obj.last_raw<br> print 'type of raw = %s' % type(obj.last_raw)<br> print 'found value = %s ' % obj.last_value<br> store = Store.of(obj)<br> raw = float(
obj.last_raw)<br> hit = HistoryHit()<br> hit.monitor = obj.monitor<br> hit.raw = raw<br> hit.value = unicode(obj.last_value)<br> hit.function = unicode(function)<br> if s_time == 'none': hit.s_date_time
= datetime.datetime.now()<br> hit.date_time = datetime.datetime.now()<br> hit.sid, hit.switch = unicode(sid), unicode(switch)<br> store.add(hit)<br><br>the print statments show me that in my test, the raw was a type float
<br>before the line that makes it one.<br>but i left the line that makes it a float in there anyway. <br>raw = float(hit.raw)<br>then later <br>hit.raw = raw<br><br>but still, the only thing showing up in the history table is 0 ( the default )
<br>and the DEBUG of the sql statement is still missing the raw as part of what gets<br>INSERT INTO history..<br><br>thanks<br>shawn<br> <br><br><br><div><span class="gmail_quote">On 8/7/07, <b class="gmail_sendername">
Adrian Klaver</b> <<a href="mailto:aklaver@comcast.net">aklaver@comcast.net</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
On Tuesday 07 August 2007 1:33 pm, shawn bright wrote:<br>> ok<br>> here is what i have for history<br>> CREATE TABLE `history` (<br>> `id` int(11) NOT NULL auto_increment,<br>> `monitor` varchar(25) NOT NULL,
<br>> `function` varchar(25) NOT NULL,<br>> `raw` float NOT NULL default '0',<br>> `value` varchar(10) NOT NULL default '0',<br>> `date_time` datetime NOT NULL default '0000-00-00 00:00:00',
<br>> `s_date_time` datetime NOT NULL default '0000-00-00 00:00:00',<br>> `sid` varchar(20) default '0',<br>> `switch` varchar(20) default '0',<br>> PRIMARY KEY (`id`),<br>> KEY `monitor` (`monitor`)
<br>> ) ENGINE=MyISAM AUTO_INCREMENT=32268398 DEFAULT CHARSET=latin1<br>> AUTO_INCREMENT=32268398 ;<br>><br>><br>> and status_hits<br>> CREATE TABLE `status_hits` (<br>> `id` int(11) NOT NULL auto_increment,
<br>> `status_sensor_id` int(11) default NULL,<br>> `raw` int(11) default NULL,<br>> `value` varchar(10) default NULL,<br>> `date_time` datetime NOT NULL default '0000-00-00 00:00:00',<br>> `sensor_time` datetime NOT NULL default '0000-00-00 00:00:00',
<br>> PRIMARY KEY (`id`),<br>> KEY `sensor_id` (`status_sensor_id`,`date_time`),<br>> KEY `date_time` (`date_time`)<br>> ) ENGINE=MyISAM AUTO_INCREMENT=17061974 DEFAULT CHARSET=latin1<br>> AUTO_INCREMENT=17061974 ;
<br>><br>><br>> And the classes<br>><br>> class StatusHit(Storm):<br>> __storm_table__ = "status_hits"<br>> id = Int(primary = True)<br>> status_sensor_id = Int()<br>> raw, value = Float(), Unicode()
<br>> date_time = DateTime()<br>> sensor_time = DateTime()<br>><br>> class HistoryHit(object):<br>> __storm_table__ = "history"<br>> id = Int(primary = True)<br>> monitor, function, value = Unicode(), Unicode(), Unicode()
<br>> raw = Float()<br>> date_time, s_date_time = DateTime(), DateTime()<br>> sid, switch = Unicode(), Unicode()<br>><br>> hope this helps<br>> and thanks for the attention for this.<br>>
<br>> shawn<br>><br><br>> > > On 8/7/07, Adrian Klaver <<a href="mailto:aklaver@comcast.net">aklaver@comcast.net</a>> wrote:<br>> > > > -------------- Original message ----------------------
<br>> > > > From: "shawn bright" <<a href="mailto:nephish@gmail.com">nephish@gmail.com</a>><br>> > > ><br>> > > > > hello again,<br>> > > > ><br>> > > > > i have a kinda different problem with and insert function i
<br>> > > > > created.<br>> > > > ><br>> > > > > here is the class<br>> > > > > class HistoryHit(object):<br>> > > > > __storm_table__ = "history"
<br>> > > > > id = Int(primary = True)<br>> > > > > monitor, function, value = Unicode(), Unicode(), Unicode()<br>> > > > > raw = Float()<br>> > > > > date_time, s_date_time = DateTime(), DateTime()
<br>> > > > > sid, switch = Unicode(), Unicode()<br>> > > > ><br>> > > > > here is the function:<br>> > > > > def make_history(obj, function, s_time = 'none', sid='none',
<br>> > > ><br>> > > > switch='none'):<br>> > > > > print '\n\n make history'<br>> > > > > print 'found object %s' % obj.monitor<br>> > > > > print 'found raw = %s' %
obj.last_raw<br>> > > > > print 'type of raw = %s' % type(obj.last_raw)<br>> > > > > print 'found value = %s ' % obj.last_value<br>> > > > > store =
Store.of(obj)<br>> > > > > hit = HistoryHit()<br>> > > > > hit.monitor = obj.monitor<br>> > > > > hit.raw = Float(obj.last_raw)<br>> > > > > hit.value
= unicode(obj.last_value)<br>> > > > > hit.function = unicode(function)<br>> > > > > if s_time == 'none': hit.s_date_time = datetime.datetime.now()<br>> > > > >
hit.date_time = datetime.datetime.now()<br>> > > > > hit.sid, hit.switch = unicode(sid), unicode(switch)<br>> > > > > store.add(hit)<br>> > > > ><br>> > > > >
<br>> > > > > the lines that call it:<br>> > > > > status_sensor.last_raw = raw<br>> > > > > status_sensor.last_value = value<br>> > > > > status_sensor.last_report =
datetime.datetime.now()<br>> > > > > hit = StatusHit()<br>> > > > > hit.status_sensor_id = status_sensor.id<br>> > > > > hit.raw = raw<br>> > > > > hit.value = value
<br>> > > > > hit.date_time = datetime.datetime.now()<br>> > > > > hit.sensor_time = sensor_time<br>> > > > > self.store.add(hit)<br>> > > > > make_history(status_sensor, 'orbcomm status', s_time = sensor_time)
<br>> > > > ><br>> > > > > INSERT INTO history (date_time, function, monitor, sid, switch,<br>> ><br>> > value)<br>> ><br>> > > > > VALUES (%s, %s, %s, %s, %s, %s) (
datetime.datetime(2007, 8, 7, 11,<br>> ><br>> > 31,<br>> ><br>> > > > 8,<br>> > > ><br>> > > > > 634691), u'orbcomm status', u'RNKE734X1', u'none', u'none', u'r')
<br>> > > > > SELECT <a href="http://history.id">history.id</a>, history.s_date_time FROM history WHERE<br>> > > > > history.id= 32246084 ()<br>> > > > ><br>> > > > >
<br>> > > > > why isn't raw added to the insert into ? the rest of the info is<br>> > > ><br>> > > > there,<br>> > > ><br>> > > > > but the raw is missing, it does show up in the terminal from the
<br>> ><br>> > print<br>> ><br>> > > > > statement though.<br>> > > > > why is there a select on history after the insert ? Nothing else<br>> ><br>> > really<br>
> ><br>> > > > > ever calls for it.<br>> > > > ><br>> > > > > thanks<br>> > > > ><br>> > > > > shawn<br>> > ><br>Just a thought but the problem may lie in this line of make_history-
<br>hit.raw = Float(obj.last_raw)<br>I think you want float(obj.last_raw).<br>If I am following the logic the value passed to status_sensor.last_raw is an<br>integer and in make_history you are changing it to a float to compensate for
<br>the difference in column types for raw between status_hits and history.<br>Float() comes from storm and as Gustavo says does something different.<br>--<br>Adrian Klaver<br><a href="mailto:aklaver@comcast.net">aklaver@comcast.net
</a><br></blockquote></div><br>