2016-10-25

pgintcl and PREPARE

pgintcl 是純粹使用 Tcl 所撰寫的 PostgreSQL client。

不過沒有實作 PQprepare 相關的部份,那麼如果要使用 prepared statement,要怎麼使用?答案是使用 PostgreSQL 的 PREPARE statement。

下面是一段簡單的 test code 的內容:
package require pgintcl

# connect to database
set db [pg_connect -conninfo "dbname=danilo user=danilo password=danilo"]

pg_execute $db "CREATE TABLE IF NOT EXISTS contact (id int, name varchar(200), primary key(id));"
pg_execute $db "PREPARE test1 AS INSERT INTO contact (id, name) VALUES (\$1, \$2);"
set res [pg_describe_prepared $db test1]
# Although Get the param type, it is the Object IDs for the Postgres data types
pg_result $res -paramTypes
pg_result $res -clear

# Need setup text or binary format, here is setup to all TEXT format
set res [pg_exec_prepared $db test1 TEXT  TEXT 1 "Raynor"]
pg_result $res -status
pg_result $res -clear

# Need setup text or binary format, here is setup to all TEXT format
set res [pg_exec_prepared $db test1 TEXT  TEXT 2 "Tassadra"]
pg_result $res -status
pg_result $res -clear

# Need setup text or binary format, here is setup to all TEXT format
set res [pg_exec_prepared $db test1 TEXT  TEXT 3 "Kavin"]
pg_result $res -status
pg_result $res -clear

pg_execute $db "PREPARE test2 AS select * from contact;"
set res [pg_describe_prepared $db test2]
# Get column number and attributes
pg_result $res -numAttrs 
pg_result $res -lAttributes
# Get param types
pg_result $res -paramTypes
pg_result $res -clear

set res [pg_exec_prepared $db test2 TEXT  TEXT]
# Get the result numbers
pg_result $res -numTuples
# Returns the query results as a Tcl dictionary
pg_result $res -dict

pg_execute $db "DROP TABLE IF EXISTS contact;"

pg_disconnect $db

這樣就可以在 pgintcl 中使用 prepared statement 了。另外 PostgreSQL 不是使用 ?,而是使用 $1, $2 來代表。

2016-10-23

Tclunqlite v0.3.1

檔案放置網頁


Tclunqlite

About

This is the UnQLite extension for Tcl using the Tcl Extension Architecture (TEA).

UnQLite is a in-process software library which implements a self-contained, serverless, zero-configuration, transactional NoSQL (Key/Value store and Document-store) database engine. This extension provides an easy to use interface for accessing UnQLite database files from Tcl.

Main Change

  1. Avoid va_arg read if it is last (merge UnQLite code)

說明


這是一個小更新版本,merge UnQLite 的一個小更新。

2016-10-22

tclcubrid v0.9

Source code:
tclcubrid


About:

CUBRID is an open source SQL-based relational database management system with object extensions developed by Naver Corporation for web applications.

tclcubrid is a Tcl extension by using CUBRID CCI (CCI Client Interface) driver to connect CUBRID. I write this extension to research CUBRID and CCI (CCI Client Interface) driver.


Main changelog:

  1. Add multiset type support
  2. CLOB/BLOB size limitation change to 1048576

加入 multiset 的支援,並且更新 CLOB/BLOB 的大小限制。

tcljsonnet v0.5

首頁:
tcljsonnet


主要更新:
將 Jsonnet code base 版本升到 v0.9.0 版。

2016-10-04

tclcubrid v0.8

Source code:
tclcubrid


About:

CUBRID is an open source SQL-based relational database management system with object extensions developed by Naver Corporation for web applications.

tclcubrid is a Tcl extension by using CUBRID CCI (CCI Client Interface) driver to connect CUBRID. I write this extension to research CUBRID and CCI (CCI Client Interface) driver.


Main changelog:

  1. Cleanup TDBC code
  2. Update README.md

簡單的更新了 TDBC paramtype 部份的 code,省略一些無效處理的部份。