TCL SQL

mysqltcl - Tcl Mysql Interface

mysqltcl - Tcl Mysql Interface (Version 3.05)

XOTclIDE - new life for Tcl.
  • interactive
  • instrospective
  • object oriented
  • syntax checking
  • version control

Mysqltcl is a simple API for Mysql-Database and Tcl scripting language.

New Version mysqltcl 3.05 (04.2008)
mysqltcl was described in March LinuxFocus online magazine

New in Version 3.05

  • applied patch from Björn König to support compilation with mysql3.23 (with help of #if). Some functionality will be disabled in this mode.
  • Some adaptions for handling multiple statement and multiple results for mysql 5. mysql::exec return a list of affected rows for multiple statement.

 

New in Version 3.04

  • checking of mysql::state parameter length was fixed. Thanks to Snyper for bug fix.

New in Version 3.03

  • patch for file mysqltcl.c to adapt mysql column comands for mysql5 was applied. This accept new columns types: newdecimal, bit and geometry. Thanks to Joerg Mehring.

New in Version 3.02

  • bug in mysql::map and mysql::recieve fixed (bug has occured by one column selects evaluated in global context)
  • updated TEA to 3.5

New in Version 3.01

  • bug in mysql::nextresult fixed
  • new command mysql::encoding for changing encoding of connection
  • new complete options for ssl connection based on C-API mysql_set_ssl

Complete Change Log


Encoding differences between 2.14 and after 2.20

Internal using of Tcl C-Api functions. For more information read Tcl C-Api manual

version-encoding valuewrite dataread data
2.14option encoding not existsTcl_UtfToExternal [encoding system]Tcl_NewByteArrayObj
2.20encoding not setTcl_UtfToExternal [encoding system]Tcl_ExternalToUtf [encoding system]
-encoding binaryTcl_GetByteArrayFromObjTcl_NewByteArrayObj
-encoding iso8859-1Tcl_UtfToExternal iso8859-1Tcl_ExternalToUtf iso8859-1

Downloads:

Windows Binary Version of mysqltcl with zip packed mysqltcl.
Release 3.05 (compiles with mysql 3, 4 and 5)

 

Release 2.51 (with new command mysqlreceive)

Old archival packages


Additional Software

  • XOSql - general onjectoriented XOTcl database access library (mysql, postgres, odbc, sqlite)
  • ATKSqlBrowser - graphical sql browser
  • XDobry - database form generator

Documentation

man2html


Authors:

  • Hakan Soderlund - primary Author of msql interface
  • Gregory Gulik - Author of mysqltcl 1.50 (original source )
  • Tobias Ritzau - Author Version 1.53 and 2.0
  • Paolo Brutti - Author of Tcl8 Object support.
  • Artur Trzewik mail@xdobry.de Author of this page, UNI-Char Support, new internal design (no 15 connection limitation), mysqlquery, mysqlendquery commands and refactoring.

Thanks to Jean-Luc Fontaine http://jfontain.free.fr for some patches.
Thanks to Alexander Schoepe for initial patch for -encoding option support.

Please conntact by bugs reports, installing problems or if you want to develop next version. Bugs Reports (mail@xdobry.de)


Installation (for version 2.15)

Use this option to install mysqltcl under FreeBSD 5.0, tcl 8.3 and mysql 3.23.54. Thanks to Diego Alberto Arias Prado

export CPP=/usr/bin/cpp
./configure --with-tcl=/usr/local/lib/tcl8.3 --with-tclinclude=/usr/local/include/tcl8.3 --with-mysql-include=/usr/local/include/mysql --with-mysql-lib=/usr/local/lib/mysql

make

make install

Installing under OpenBSD 3.1. Thanks to Fredrick Leitz.

LDFLAGS="-I/usr/local/lib/mysql -I/usr/local/lib/tcl8.3"
CPPFLAGS="-I/usr/local/include/mysql -I/usr/local/include/tcl8.3/generic"
export LDFLAGS  CPPFLAGS
./configure
make
make install
Mac OS X

with gcc

./configure CC=gcc --with-mysql-include=/Library/MySQL/include/mysql --with-mysql-lib=/Library/MySQL/lib/mysql/

thanks to Justin Dewind

with fink

./configure --with-mysql-include=/sw/include/mysql --with-mysql-lib=/sw/lib/mysql --with-tcl=/sw/lib --with-tclinclude=/sw/include

thanks to eric lebel

FAQ and Pitfalls

Commands out of sync; You can't run this command now

This error happens when you have used mysqlexec command with SQL select command, that normally should return result set. The next mysql command (mysqlsel mysqlexec mysqlmap) causes that error. You can use mysqlexec only for (INSER, DELETE and UPDATA Sql commands). For SELECT command you should use mysqlsel mysqlquerry mysqlmap mysqreceive.

Segmentation fault by connecting mysql with version earlier than 3.23.50

The earlier version of mysql have had bug in mysql_option function that was fixed in 3.23.50 see mysql changes log News 3.23.50 . This can happens to Debian user of very old and "very stable" release. If you do not want to upgrade your system, please use mysqltcl 2.50 or later or comment out the line mysql_options(handle->connection,MYSQL_READ_DEFAULT_GROUP,groupname); from mysqltcl.c file. Then the .my.cnf file will be not recognized.

How mysqltcl handles UNI-coded (UTF8) strings till version 2.14?

All sql statments are converted to external representation by using Tcl_UtfToExternalDString function before sending to database. This function use character set specified by [encoding system] variable. All data read from database are treated as byte array. (By using function Tcl_NewByteArrayObj ). If you want to convert this data to your representation use tcl function [encoding convertto ?encoding? string].
In Version 2.20 another way was chosen please read manual section mysqlconnect option -encoding.

The compilation and installation was OK but I got the message: "couldn't load file "libmysqltcl2.12.so": libmysqltcl2.12.so: cannot open shared object file: No such file or directory"

mysqltcl is dynamical linked with libmysqlclient. If the libmysqlclient library is not in the dynamical library path mysqltcl could not be loaded. Try "ldd libmysqltcl2.12.so" to see all dependences.

ldd libmysqltcl2.12.so
   libmysqlclient.so.10 => /usr/local/mysql/lib/mysql/libmysqlclient.so.10 (0x40007000)
   libc.so.6 => /lib/libc.so.6 (0x40030000)
   libz.so.1 => /lib/libz.so.1 (0x40143000)
   libcrypt.so.1 => /lib/libcrypt.so.1 (0x40152000)
   libnsl.so.1 => /lib/libnsl.so.1 (0x40180000)
   libm.so.6 => /lib/libm.so.6 (0x40196000)
   /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)

You can adapt LD_LIBRARY_PATH environment variable to the libmysqlclient library. You can also try to link libmysqlclient statical. You must adapt Makefile for it.
You can use option --enable-mysqlstatic in configure script for build mysql static linked with mysqlclient library.

I got also following message from sun user:
However, the correct fix is NOT to adjust LD_LIBRARY_PATH; see LDPATH for details of why that is a bad solution. Rather, one needs to adjust the configure options to embed the path to the required library in the referring library. On Solaris 11, I use this configuration line:

./configure LIBS=-R/opt/mysql/mysql/lib --with-mysql-include=/opt/mysql/mysql/include --with-mysql-lib=/opt/mysql/mysql/lib --enable-shared
--with-tcl=/opt/ActiveTcl-8.5/lib --with-tclinclude=/opt/ActiveTcl-8.5/include

and the LIBS setting does the right thing in that regard. Something similar is the right way to handle this problem under Linux, as well.

I get the message: "sh: syntax error at line 1: `;' unexpected" by make install

This problem was reported by Sun and Compaq Tru64 machines. It seems the shell on this machines have another syntax then linux shell. I have seen in news groups that problem also by another linux projects. To solve the problem you should set some magic environment variable to change compatibility behaviour of your shell. If someone has near information please mail me it. There are 2 important files that you can also copy manual.

/usr/lib/mysqltcl-2.11/libmysqltcl2.11.so
/usr/lib/mysqltcl-2.11/pkgIndex.tcl

I can not find tclmysqlsh (Tcl with mysqltcl shell) provided in earlier versions

You should use package mechanisms. It is more portable and the right way in Tcl.

package require mysqltcl 

I become some differences in encoding by receiving results from (mysqlsel $sql -list, mysqlsel $sql -flatlist, mysqlnext)

mysql $sql -list returns list of list. mysql $sql -flatlist returns a list. mysqlnext returns a list. Even if you retrieve one row and one column you becomes list structures. If you handle such results as string when tcl must convert the list to string. It is better to use lindex command to access directly the list elements (even then there are only one element) to avoid internal types converting. (Such converting can also change the encoding of the string elements)

set result [lindex [lindex [mysqlsel $handle "select blob from pictures where id=2" -list] 0] 0]
set result [lindex [mysqlsel $handle "select blob from pictures where id=2" -flatlist] 0]
mysqlsel $handle "select blob from pictures where id=2" 
set result [lindex [mysqlnext $handle] 0]

There are some problems by retrieving binary data from mysql by some installations.

By problems you should use.

mysqlconnect -encoding binary

Up from version 2.20 mysql use symetric read and write. That means you do not need to uses enocding converting. But consider if you write binary data to mysql they are converted to system encoding that means you write binary and they can be in mysql as utf-8. See exmaple in tests/binarytest.tcl.
In version to 2.14 you can use to get binary data read from database.

encoding convertfrom [encoding system] $sql_read_data

Problems by build static linked mysqltcl on Solaris; with option --enable-mysqlstatic

The configuration script with this option work good only for Linux. I have not found any way to make it machine independent.

Jean-Luc have reporterted an alternative manually way to static compile mysqltcl on Solaris 5.9

$ ld -G -o libmysqltcl2.40.so mysqltcl.o  /usr/local/mysql/lib/libmysqlclient.a -lz -lcrypt -lnsl -lm -L/home/mysql/tcltk/lib -ltclstub8.4 -lc -lsocket -ldl

Projects that use mysqltcl

  • Moods Moodss is a graphical monitoring application.
  • nstcl package which reimplements many of the useful APIs and commands from AOLserver and OpenACS.
  • TKSql GUI to edit postgreSQL and MySQL tables.
  • QuoteEngine The QuoteEngine is a IRC quote database script for eggdrop which interfaces with mySQL to store the quotes. Mysql seems to be wide used by eggdrop.
  • Sguil Sguil (pronounced "sgweel") is a graphical interface to snort, an open source intrusion detection system.
  • Hammerora is an open source load generation tool for the Oracle Database, MySQL Database and HTML environments

If you use mysqltcl internal in your project and you do not fear to angry your business partner (this big software partner!) by talking about it, please report it me. I want to publish some users stories one this site. It will help another users to assess the stability and usability of mysqltcl and also Tcl and MYSQL. The interesting things were performance, development costs, comparitions to another systems. What is the mysqltcl using for in real life? (50-100 downloads a week) It will also help to improve future versions.

Another Tcl mysql Interfaces:

  • tcl-sql The Tcl Generic Database Interface. Query-results have their own handles. No seek and no newinsertid commands. Programmed in C++
  • FastBase MySQL + Tcl Interface Program Not tested: no seek, no result introspection, no newinsertid.

WEB-Master Artur Trzewik

Last modified: Tue Dec 28 14:29:30 CET 2004

 

 

原文地址:http://www.xdobry.de/mysqltcl/

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值