ok, here is my new function:<br>def make_history(obj, function, s_time = &#39;none&#39;, sid=&#39;none&#39;, switch=&#39;none&#39;):<br>&nbsp;&nbsp;&nbsp; print &#39;\n\n make history&#39;<br>&nbsp;&nbsp;&nbsp; print &#39;found object %s&#39; % obj.monitor
<br>&nbsp;&nbsp;&nbsp; print &#39;found raw = %s&#39; % obj.last_raw<br>&nbsp;&nbsp;&nbsp; print &#39;type of raw = %s&#39; % type(obj.last_raw)<br>&nbsp;&nbsp;&nbsp; print &#39;found value = %s &#39; % obj.last_value<br>&nbsp;&nbsp;&nbsp; store = Store.of(obj)<br>&nbsp;&nbsp;&nbsp; raw = float(
obj.last_raw)<br>&nbsp;&nbsp;&nbsp; hit = HistoryHit()<br>&nbsp;&nbsp;&nbsp; hit.monitor = obj.monitor<br>&nbsp;&nbsp;&nbsp; hit.raw = raw<br>&nbsp;&nbsp;&nbsp; hit.value = unicode(obj.last_value)<br>&nbsp;&nbsp;&nbsp; hit.function =&nbsp; unicode(function)<br>&nbsp;&nbsp;&nbsp; if s_time == &#39;none&#39;: hit.s_date_time
 = datetime.datetime.now()<br>&nbsp;&nbsp;&nbsp; hit.date_time = datetime.datetime.now()<br>&nbsp;&nbsp;&nbsp; hit.sid, hit.switch = unicode(sid), unicode(switch)<br>&nbsp;&nbsp;&nbsp;  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>&nbsp;&nbsp; <br><br><br><div><span class="gmail_quote">On 8/7/07, <b class="gmail_sendername">
Adrian Klaver</b> &lt;<a href="mailto:aklaver@comcast.net">aklaver@comcast.net</a>&gt; 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>&gt; ok<br>&gt; here is what i have for history<br>&gt; CREATE TABLE `history` (<br>&gt;&nbsp;&nbsp; `id` int(11) NOT NULL auto_increment,<br>&gt;&nbsp;&nbsp; `monitor` varchar(25) NOT NULL,
<br>&gt;&nbsp;&nbsp; `function` varchar(25) NOT NULL,<br>&gt;&nbsp;&nbsp; `raw` float NOT NULL default &#39;0&#39;,<br>&gt;&nbsp;&nbsp; `value` varchar(10) NOT NULL default &#39;0&#39;,<br>&gt;&nbsp;&nbsp; `date_time` datetime NOT NULL default &#39;0000-00-00 00:00:00&#39;,
<br>&gt;&nbsp;&nbsp; `s_date_time` datetime NOT NULL default &#39;0000-00-00 00:00:00&#39;,<br>&gt;&nbsp;&nbsp; `sid` varchar(20) default &#39;0&#39;,<br>&gt;&nbsp;&nbsp; `switch` varchar(20) default &#39;0&#39;,<br>&gt;&nbsp;&nbsp; PRIMARY KEY&nbsp;&nbsp;(`id`),<br>&gt;&nbsp;&nbsp; KEY `monitor` (`monitor`)
<br>&gt; ) ENGINE=MyISAM AUTO_INCREMENT=32268398 DEFAULT CHARSET=latin1<br>&gt; AUTO_INCREMENT=32268398 ;<br>&gt;<br>&gt;<br>&gt; and status_hits<br>&gt; CREATE TABLE `status_hits` (<br>&gt;&nbsp;&nbsp; `id` int(11) NOT NULL auto_increment,
<br>&gt;&nbsp;&nbsp; `status_sensor_id` int(11) default NULL,<br>&gt;&nbsp;&nbsp; `raw` int(11) default NULL,<br>&gt;&nbsp;&nbsp; `value` varchar(10) default NULL,<br>&gt;&nbsp;&nbsp; `date_time` datetime NOT NULL default &#39;0000-00-00 00:00:00&#39;,<br>&gt;&nbsp;&nbsp; `sensor_time` datetime NOT NULL default &#39;0000-00-00 00:00:00&#39;,
<br>&gt;&nbsp;&nbsp; PRIMARY KEY&nbsp;&nbsp;(`id`),<br>&gt;&nbsp;&nbsp; KEY `sensor_id` (`status_sensor_id`,`date_time`),<br>&gt;&nbsp;&nbsp; KEY `date_time` (`date_time`)<br>&gt; ) ENGINE=MyISAM AUTO_INCREMENT=17061974 DEFAULT CHARSET=latin1<br>&gt; AUTO_INCREMENT=17061974 ;
<br>&gt;<br>&gt;<br>&gt; And the classes<br>&gt;<br>&gt; class StatusHit(Storm):<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; __storm_table__ = &quot;status_hits&quot;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id = Int(primary = True)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;status_sensor_id = Int()<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;raw, value = Float(), Unicode()
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;date_time = DateTime()<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sensor_time = DateTime()<br>&gt;<br>&gt;&nbsp;&nbsp;class HistoryHit(object):<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; __storm_table__ = &quot;history&quot;<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;id = Int(primary = True)<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;monitor, function, value = Unicode(), Unicode(), Unicode()
<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;raw = Float()<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;date_time, s_date_time = DateTime(), DateTime()<br>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sid, switch = Unicode(), Unicode()<br>&gt;<br>&gt; hope this helps<br>&gt; and thanks for the attention for this.<br>&gt;
<br>&gt; shawn<br>&gt;<br><br>&gt; &gt; &gt; On 8/7/07, Adrian Klaver &lt;<a href="mailto:aklaver@comcast.net">aklaver@comcast.net</a>&gt; wrote:<br>&gt; &gt; &gt; &gt;&nbsp;&nbsp;-------------- Original message ----------------------
<br>&gt; &gt; &gt; &gt; From: &quot;shawn bright&quot; &lt;<a href="mailto:nephish@gmail.com">nephish@gmail.com</a>&gt;<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; hello again,<br>&gt; &gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; i have a kinda different problem with and insert function i
<br>&gt; &gt; &gt; &gt; &gt; created.<br>&gt; &gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; here is the class<br>&gt; &gt; &gt; &gt; &gt; class HistoryHit(object):<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; __storm_table__ = &quot;history&quot;
<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; id = Int(primary = True)<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; monitor, function, value = Unicode(), Unicode(), Unicode()<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; raw = Float()<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; date_time, s_date_time = DateTime(), DateTime()
<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; sid, switch = Unicode(), Unicode()<br>&gt; &gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; here is the function:<br>&gt; &gt; &gt; &gt; &gt; def make_history(obj, function, s_time = &#39;none&#39;, sid=&#39;none&#39;,
<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; switch=&#39;none&#39;):<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; print &#39;\n\n make history&#39;<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; print &#39;found object %s&#39; % obj.monitor<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; print &#39;found raw = %s&#39; % 
obj.last_raw<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; print &#39;type of raw = %s&#39; % type(obj.last_raw)<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; print &#39;found value = %s &#39; % obj.last_value<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; store = 
Store.of(obj)<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; hit = HistoryHit()<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; hit.monitor = obj.monitor<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; hit.raw = Float(obj.last_raw)<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; hit.value
 = unicode(obj.last_value)<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; hit.function =&nbsp;&nbsp;unicode(function)<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; if s_time == &#39;none&#39;: hit.s_date_time = datetime.datetime.now()<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; 
hit.date_time = datetime.datetime.now()<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; hit.sid, hit.switch = unicode(sid), unicode(switch)<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; store.add(hit)<br>&gt; &gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; &gt;
<br>&gt; &gt; &gt; &gt; &gt; the lines that call it:<br>&gt; &gt; &gt; &gt; &gt; status_sensor.last_raw = raw<br>&gt; &gt; &gt; &gt; &gt; status_sensor.last_value = value<br>&gt; &gt; &gt; &gt; &gt; status_sensor.last_report = 
datetime.datetime.now()<br>&gt; &gt; &gt; &gt; &gt; hit = StatusHit()<br>&gt; &gt; &gt; &gt; &gt; hit.status_sensor_id = status_sensor.id<br>&gt; &gt; &gt; &gt; &gt; hit.raw = raw<br>&gt; &gt; &gt; &gt; &gt; hit.value = value
<br>&gt; &gt; &gt; &gt; &gt; hit.date_time = datetime.datetime.now()<br>&gt; &gt; &gt; &gt; &gt; hit.sensor_time = sensor_time<br>&gt; &gt; &gt; &gt; &gt; self.store.add(hit)<br>&gt; &gt; &gt; &gt; &gt; make_history(status_sensor, &#39;orbcomm status&#39;, s_time = sensor_time)
<br>&gt; &gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; INSERT INTO history (date_time, function, monitor, sid, switch,<br>&gt; &gt;<br>&gt; &gt; value)<br>&gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; VALUES (%s, %s, %s, %s, %s, %s) (
datetime.datetime(2007, 8, 7, 11,<br>&gt; &gt;<br>&gt; &gt; 31,<br>&gt; &gt;<br>&gt; &gt; &gt; &gt; 8,<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; 634691), u&#39;orbcomm status&#39;, u&#39;RNKE734X1&#39;, u&#39;none&#39;, u&#39;none&#39;, u&#39;r&#39;)
<br>&gt; &gt; &gt; &gt; &gt; SELECT <a href="http://history.id">history.id</a>, history.s_date_time FROM history WHERE<br>&gt; &gt; &gt; &gt; &gt; history.id= 32246084 ()<br>&gt; &gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; &gt;
<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;why isn&#39;t raw added to the insert into ?&nbsp;&nbsp;the rest of the info is<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; there,<br>&gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; but the raw is missing, it does show up in the terminal from the
<br>&gt; &gt;<br>&gt; &gt; print<br>&gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; statement though.<br>&gt; &gt; &gt; &gt; &gt;&nbsp;&nbsp;why is there a select on history after the insert ? Nothing else<br>&gt; &gt;<br>&gt; &gt; really<br>
&gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; ever calls for it.<br>&gt; &gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; thanks<br>&gt; &gt; &gt; &gt; &gt;<br>&gt; &gt; &gt; &gt; &gt; shawn<br>&gt; &gt; &gt;<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>