[http://naviserver.sourceforge.net/ns_logobig.gif] [NaviServer%|%Main%|%] ✸ http://bitbucket.org/naviserver/naviserver/%|%Source Code %|% ✸ http://sourceforge.net/project/showfiles.php?group_id=130646%|%Downloads %|% ✸ http://naviserver.sourceforge.net/n/toc.html%|%API Documentation %|% ✸ http://sourceforge.net/mail/?group_id=130646%|%Mailing Lists%|% ✸ http://sourceforge.net/tracker/?group_id=130646&atid=719006%|%Bugs %|% ✸ https://www.ohloh.net/p/naviserver/contributors%|%Developers %|% ---- '''nsdbi''' - [NaviServer] Database Interface set formatted_result [dbi_rows {select first, last from people where id = :id} {
  • $first $last
  • }] nsdbi provides a Tcl interface to an SQL database from within the [naviserver] web server (and, potentially from within a tclsh). It is a combination of the ideas from the original ns_db interface (available standalone as [nstcl]) and the higher level interface provided by [openacs]. Some new features include: * '''Bind Variables'''. The original ns_db interface had no support, and the openacs interface supports it with an extension for oracle and through emulation for postgres. A uniform syntax (:variablename) is supported for all databases. In the example above, :id is a bind variable and the value of the Tcl variable $id is passed to the database to substitute. * '''Prepared Statements'''. All statements are prepared when first seen and the handle is cached using the query as the key. This is transparent to the Tcl programmer. * '''Handle Management'''. A pool of handles is maintained, shared among all threads/interps. Handles are retrieved from the pool when needed and returned after each command. In the above example, the default handle is being used. The '''-db''' ''name'' option may be used to specify some other handle. * '''High Performance'''. The code operates reasonably quickly: in the example above, no Tcl objects are allocated at runtime. The query and template are parsed once and cached. The formatted result is assembled by appending the bytes directly into the result buffer. See the documentation[http://www.groks.org/nsdbi.n.html] for more. Drivers are available for: * [Postgres]: [nsdbipg] * [MySQL]: [nsdbimy] (connecting to a server, and embedded) * [SQLite]: [nsdbilite] Documentation: * http://naviserver.sourceforge.net/n/nsdbi/files/nsdbi.html Download: * http://sourceforge.net/project/showfiles.php?group_id=130646 Source Code: $ hg clone https://bitbucket.org/naviserver/nsdbi/ [https://www.ohloh.net/p/nsdbi/analyses/latest/commits_spark.png] See Also: * [Comparing Tcl database abstraction layers] ---- '''Comments''' ... ---- !!!!!! %| [Category Database] | [Category NaviServer] |% !!!!!!