nsmcp::SQLiteDatabase method session (public)
<instance of nsmcp::SQLiteDatabase> session handle
Defined in /usr/local/ns/tcl/nsmcp/database.tcl
Adapt a caller-owned handle without taking ownership of checkout. Use within ns_db withhandle; close the adapter before leaving that scope. Validation and page-budget errors leave checkout to the caller.
- Parameters:
- handle (required)
- Checked-out SQLite handle from this database's pool.
- Returns:
- A borrowed DatabaseSession, local to the caller's operation.
- Testcases:
- No testcase defined.
Source code: if {[ns_db poolname $handle] ne ${:pool} || [ns_db dbtype $handle] ne "sqlite"} { error "MCP databasePool must use nsdbsqlite and its configured pool" } set source [ns_db datasource $handle] if {$source eq "" || $source eq ":memory:" || [string match file:* $source]} { error "MCP cache requires a persistent file datasource" } set :path [file normalize $source] file attributes ${:path} -permissions 0600 set db [::nsmcp::DatabaseSession new -handle $handle -ownsHandle false] try { set pages [expr {int(${:maxBytes}*0.45)/[$db scalar {PRAGMA page_size}]}] set current [$db scalar {PRAGMA page_count}] if {$current>$pages} { error "existing database exceeds configured byte budget" } $db execute "PRAGMA max_page_count=$pages" return $db } on error {message options} { $db close return -options $options $message }XQL Not present: Generic, PostgreSQL, Oracle
![[i]](/resources/acs-subsite/ZoomIn16.gif)