<br><br><div class="gmail_quote">On Dec 26, 2007 3:24 PM, Hans-Christoph Steiner &lt;<a href="mailto:hans@eds.org">hans@eds.org</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div style="word-wrap:break-word">
<div><br></div><div>My idea for using this would be to pair the [sql_query] directly to the [sqlite] object, then the rest of the time, the data would be in the form of Pd messages. &nbsp;I think for most people, they&#39;ll want to work in Pd messages as much as possible, then at the last possible moment, the Pd messages should be converted into SQL queries.
</div></div></blockquote><div><br class="webkit-block-placeholder"></div><div>I guess I don&#39;t see the &quot;pairing&quot; as being necessary. There is usually only one object that represents a database, and while there can be two or more (each handling its own set of result sets, I think of this as being multiple &quot;data channels&quot; into a single database), the result sets still I think should be coming out of the query object, as that is the place that is mostly associated with that particular query.
</div><div>&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word"><div>Also, since Pd objects visually represent instances, I think that the [sqlite] server object should represent one database. &nbsp;If there are numerous [sqlite] objects representing the same database, then I think things will get confusing to the Pd user and in the C code. &nbsp;We tried this in hidio, and it turned out to be a pain. &nbsp;I am not sure if this is what you are proposing, though, but that is my understanding of it.
</div></div></blockquote><div><br class="webkit-block-placeholder"></div><div>Hum, well, I don&#39;t see this as being a problem, as a matter of fact, I think this will be a plus, as it would allow the creation of multiple connections to a single database, one that might handle only inserts, another than would handle selects. As it currently stands, each database server instance can only handle one set of results sets at a time. Each instance would free us from having to deal with two different queries trying to make requests at the same time.
</div><div><br class="webkit-block-placeholder"></div><div>As it stands right now, each of my server objects is given a PD symbol ID, and that is passed to each of the query objects. The query object sends any requests directly to the server object (yes, I know, that is behind the scenes, but it is similar to a &#39;netsend&#39; object.). The connections being made are purely symbolic, and can even be changed on each query instance.
</div><div>&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word"><div>I&#39;ll take a look at your design once its out there.</div>
</div></blockquote><div><br class="webkit-block-placeholder"></div><div>You might be surprised at the differences between our implementations. I will say, though, that I see how you are handling char buffers, and I will have to look into just how PD actually works with &#39;binbuf&#39; objects.
</div><div><br class="webkit-block-placeholder"></div><div>Mike</div><div><br class="webkit-block-placeholder"></div><div>&nbsp;</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div style="word-wrap:break-word"><div></div><div><br></div><div>.hc</div><div><div></div><div class="Wj3C7c"><br><div><div>On Dec 26, 2007, at 10:28 AM, Mike McGonagle wrote:</div><br><blockquote type="cite">Hans,<div><br>
</div><div>From looking at this (I didn&#39;t compile the external yet), but my first thought about your patch is that it would be very cumbersome to have the result sets coming out of the &quot;server&quot; object. They should be coming out of the &quot;query&quot; object, as that is the object that is handling that particular result set. I kind of envision that once someone has finished with creating the SQL queries, that they would then create the processing code to handle each query. That is something that is specific to the query, and not the &quot;server&quot; object. The way that you have this, we would still need to create a separate &quot;query&quot; and &quot;server&quot; object for each query. That would make swapping the &quot;server&quot; object in and out very difficult, as it would require replacing ALL of the &quot;server&quot; objects for each query. 
</div><div><br></div><div>Just to let you know, I need to clean up some more stuff, but I will post my latest version of the &quot;server&quot; and &quot;query&quot; objects tomorrow. I have not done a whole lot of testing, but I am able to insert SQL and make the queries, and get results out. It also handles errors and most recent insert row id stuff... 
</div><div><br></div><div>Mike</div><div><br><br><div class="gmail_quote">On Dec 22, 2007 1:27 AM, Hans-Christoph Steiner &lt;<a href="mailto:hans@eds.org" target="_blank">hans@eds.org</a>&gt; wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
 <div style="word-wrap:break-word"> <div><br></div><div>I just committed my first stabs at a sketch for the [sql_query] object. &nbsp;It doesn&#39;t do anything yet, but it does recognize ? placeholders as object arguments and creates inlets. &nbsp;Other than that, the only thing it currently does is crash :). 
</div><div><br></div><div><a href="http://pure-data.cvs.sourceforge.net/pure-data/externals/hcs/sql_query-help.pd" target="_blank">http://pure-data.cvs.sourceforge.net/pure-data/externals/hcs/sql_query-help.pd</a></div><div>
 <a href="http://pure-data.cvs.sourceforge.net/pure-data/externals/hcs/sql_query.c" target="_blank">http://pure-data.cvs.sourceforge.net/pure-data/externals/hcs/sql_query.c</a></div><div><br></div><div>.hc</div><br><div><div>
 <div>On Dec 21, 2007, at 1:36 PM, Mike McGonagle wrote:</div><br></div><div><div></div><div><blockquote type="cite"><br><br><div><span class="gmail_quote">On 12/21/07, <b class="gmail_sendername">Mathieu Bouchard </b> &lt;
<a href="mailto:matju@artengine.ca" target="_blank">matju@artengine.ca</a>&gt; wrote:</span><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"> On Tue, 18 Dec 2007, Mike McGonagle wrote: 
<br><br>&gt; [query &lt;srv_id&gt; insert into mytable (id, name, token) values (?f,&#39;?s&#39;,&#39;?s&#39;)]<br>&gt; In this example, the first placeholder would expect a Float, with the next <br>&gt; two expecting a Symbol (just think of this as a variation on the printf 
<br>&gt; string substitutions).<br><br>It looks more like the types of [t] [pack] [unpack] [expr] etc.</blockquote><div><br> </div><div><br></div><div>Yes, they are PD types.</div></div></blockquote><br></div></div><blockquote type="cite">
 <div><div></div><div><div><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">You don&#39;t really need to type your data. SQL is largely typeless: at least <br>
at the level of what you can put in one table cell, anything is a string.<br>It becomes typed (but auto-cast) when put in the cell, but rebecomes<br>untyped when taken out of the cell.</blockquote><div><br> </div><div> <br>
</div><div>Yes, I know that these things can be stored in a typeless manner, but the functions that bind the SQL statement with their placeholders can be of any type, as there are functions for the various datatypes.&nbsp; </div>
<div><br></div><div><a href="http://www.sqlite.org/c3ref/bind_blob.html" target="_blank">http://www.sqlite.org/c3ref/bind_blob.html</a></div><div><br></div><div>This link shows all the different functions used to bind the data to the statement placeholders. 
</div><div><br></div><div><a href="http://dev.mysql.com/doc/refman/5.0/en/c-api-prepared-statement-datatypes.html" target="_blank">http://dev.mysql.com/doc/refman/5.0/en/c-api-prepared-statement-datatypes.html </a></div><div>
 <br></div><div>And if you look at how MySQL does this, while they only provide a single bind function, it does have the datatypes for the data in a structure that gets passed into the bind function. </div><div><br></div>
<div> Also, from looking at libdbi, it appears that they don&#39;t even bother with placeholders at all.</div><div><br></div><div>This is not an issue of how the user sees these things, it is how the C code interfaces with the database. &nbsp; 
</div><div><br></div><div>So, just how do we do this in a consistent manner when all the different interfaces don&#39;t support these things, AND if they do, they do them differently.</div> <br><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">
 &gt; but considering that the databases need to know the specific data types<br>&gt; for each placeholder, <br><br>heh? do they?</blockquote><div><br></div><div><br></div><div>SQLite does. MySQL appears to as well. And yes, it is possible to just force everything to be a string/c-string and be done with it. SQLite actually stores everything as a string anyway,&nbsp;despite&nbsp;the defined types in the create statement. 
</div><div><br></div><div>Mike</div><div><br></div><br><blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"> &nbsp;&nbsp;_ _ __ ___ _____ ________ _____________ _____________________ ... 
<br>| Mathieu Bouchard - tél:+1.514.383.3801, Montréal QC Canada</blockquote></div><br><br clear="all"><br>-- <br>Peace may sound simple—one beautiful word— but it requires everything we have, every quality, every strength, every dream, every high ideal. 
<br>—Yehudi Menuhin (1916–1999), musician </div></div><div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">_______________________________________________</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
 <a href="mailto:PD-list@iem.at" target="_blank">PD-list@iem.at</a> mailing list</div><div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">UNSUBSCRIBE and account-management -&gt; <a href="http://lists.puredata.info/listinfo/pd-list" target="_blank">
 http://lists.puredata.info/listinfo/pd-list</a></div> </div></blockquote></div><br><div> <span style="border-collapse:separate;border-spacing:0px 0px;color:rgb(0, 0, 0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
 <br><div><br></div><div><br></div><div>----------------------------------------------------------------------------<br></div><div><br></div><div>&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;kill your television</div><br></span> </div><br>
 </div></blockquote></div><br><br clear="all"><br>-- <br>Peace may sound simple—one beautiful word— but it requires everything we have, every quality, every strength, every dream, every high ideal.<br>—Yehudi Menuhin (1916–1999), musician 
</div></blockquote></div><br></div></div><div> <span style="border-collapse:separate;border-spacing:0px 0px;color:rgb(0, 0, 0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<br><span style="border-collapse:separate;border-spacing:0px 0px;color:rgb(0, 0, 0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">
<div><br></div><div>----------------------------------------------------------------------------</div><div><br></div><div>I have the audacity to believe that peoples everywhere can have three meals a day for their bodies, education and culture for their minds, and dignity, equality and freedom for their spirits.&nbsp; &nbsp; &nbsp;
<span>&nbsp;</span>- Martin Luther King, Jr.</div><br></span></span> </div><br></div></blockquote></div><br><br clear="all"><br>-- <br>Peace may sound simple—one beautiful word— but it requires everything we have, every quality, every strength, every dream, every high ideal.
<br>—Yehudi Menuhin (1916–1999), musician