<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><span></span></div><br><div><div><div>On Dec 11, 2007, at 4:20 PM, Mike McGonagle wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">(As the other thread seemed to diverge greatly in topic, I figured this might be a time to branch off and discuss what we are trying to implement)<div><br> </div><div>So, can we take a step back and figure out exactly what we are doing? It seems that even within the thread itself, we have changed the Object Model a LOT... From what I have read, this is what I now understand the model to be... </div><div><br> </div><div><br>[mySQL-Connection id-symbol &lt;connection info&gt;] &lt;-- a PD object representing connection</div></blockquote><br><blockquote type="cite"><div><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">[SQL-Query id-symbol &lt;sql statement&gt;] &lt;-- an SQL query object</span></div><div><br><br></div><div> </div><div>The first object, the Connection, takes a symbol that identifies itself to PD, and optionally the connection info. The second takes a symbol linking it to a Connection object (this linking can also be changed to point to another connection using a control message), and an optional SQL statement for Placeholder Inlet creation. This method will "bind" those inlets into the SQL statement. If there is no SQL statement, no binding is allowed using that object, and all SQL come to a cold inlet, using PD messages (variable stuff can be put into the statement via PD's $ mechanism).</div></blockquote><div><br class="webkit-block-placeholder"></div><div>Sounds good, but I don't think we need the 'id-symbol' in the query, the results would just be feed from the query's outlet to the connection's inlets.</div><br><blockquote type="cite"><div> </div><div><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">The connection object responds to the following</span></div><div>open/connect - to open a file (in an embedded database) or connects to server</div><div>close/disconnect - close the file or breaks the connection </div><div><br> </div><div>As the connection object can represent any database, its named &lt;dbname-connect&gt;. A MySQL database would be [MySQL-connect ...], sqlite would be [sqlite-connect ...], etc. A connection object provides a single outlet to provide status about the connection (similar to a [netsend] object). There is a single inlet used to control the connection object.</div></blockquote><div><br class="webkit-block-placeholder"></div><div>I think the original names for the connection/database objects are good: psql, sqlite, mysql.  Then for queries, there could be a generic object.  That generic object wouldn't need to understand the SQL, so it should be able to handle the variants.  The only thing it needs to understand is the placeholder stuff.  Then for the various databases, we do placeholder translation where necessary (this is how things like Perl:DBI handle it, AFAIK).</div><div><br class="webkit-block-placeholder"></div><div>[sql_query]   -   (generic SQL constructs)</div><div><br class="webkit-block-placeholder"></div><div>Then if need be:</div><div>[psql_query]</div><div>[mysql_query]</div><div>[sqlite_query]</div><div><br class="webkit-block-placeholder"></div><br><blockquote type="cite"><div> </div><div><br class="webkit-block-placeholder"></div><div>The query object responds to the following</div><div>buffer - to change the size of the SQL input buffer</div></blockquote><blockquote type="cite"><div>results - to change the size of the results buffer</div></blockquote><div><br class="webkit-block-placeholder"></div>As long as the "buffer"  and "results" messages are optional, then it's fine by me.  If possible, things should work without having to set these, then these would be for performance tweaks.</div><div><br><blockquote type="cite"><div> </div><div>bang - submits the initial query, and outputs a result set for each bang</div><div>clear - clears the SQL buffer</div></blockquote><div><br></div><div>Sounds good.</div><br><blockquote type="cite"><div>addsemi - appends a semicolon to the SQL buffer</div><div>addcomma - appends a comma to the SQL buffer </div><div>adddollar - appends a dollar sign to the buffer (do we need this?)</div></blockquote><div><br class="webkit-block-placeholder"></div><div>If you want to be able to add the string $1 to a database, then we need the adddollar message.</div><br><blockquote type="cite"><div><br class="webkit-block-placeholder"></div><div>If the query is created with an embedded statement, any placeholders will generate an inlet. No cold inlet for SQL will be created.</div></blockquote><div><br class="webkit-block-placeholder"></div><div>Sounds good.</div><br><blockquote type="cite"><div> </div><div><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">If the query does not have an embedded statement, it will provide an arbitrary inlet that accepts SQL to process.</span></div></blockquote><div><br class="webkit-block-placeholder"></div><div>If the connection object has the arbitrary SQL cold inlet, I am not sure we need the same functionality in the query object, but I could be wrong.</div><br><blockquote type="cite"><div><span class="Apple-style-span" style="-webkit-text-stroke-width: -1; ">The query object has 3 outlets, the first outputs a list for each result set (on each subsequent bang, very much like a [textfile] object), the second will outlet a float representing the ROWID of the last insert statement, and the third outlet indicates the status of the query, with a bang indicating the end of the result sets, a symbol or a list is a status message from the database.</span></div></blockquote><div><br class="webkit-block-placeholder"></div><div>query objects would just be a handy way to generate queries to send to the connection object.  So the outlets would be designed to plug straight into the inlets of the connection object.  Then I think the above outlets you describe would be on the connection object, which returns the results.</div><div><br></div><br><blockquote type="cite"><div><br class="webkit-block-placeholder"></div><div>*************************</div><div><br class="webkit-block-placeholder"></div><div>Does this sound about right? I would like to have a clear outline before I start coding anything<br></div> </blockquote><br></div><div>Indeed, it's time for some coding!  I am thinking of coding up a version of the [sql_query] object if no one has any objections.  Ultimately, I think we should decide on a name for a common library, then start building it out as a unified library of database things.  First, let's get a working interface that we all like :).</div><div><br></div><div>.hc</div><div><br class="webkit-block-placeholder"></div><br><div> <span class="Apple-style-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; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-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; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-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; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><br class="Apple-interchange-newline"><div>----------------------------------------------------------------------------</div><div><br class="khtml-block-placeholder"></div><div>Access to computers should be unlimited and total.  - the hacker ethic</div><br class="Apple-interchange-newline"></span></span></span> </div><br></div></body></html>