FastBase MySQL + Tcl Interface Program
Summary Documentation Notes Download Build Notes Author License Change History

Summary

This Tcl extension provides access to MySQL database servers using simple Tcl commands.

I wrote this extension because my main Tcl application (fully integrated accounting system) was requiring more flexibility than the current extensions allowed, I also wanted to increase performance (I had too many wrapper programs for performing basic queries).

Documentation

The documentation is provided here (right click to download).

Here is a sample piece of code using fbsql:

# load the fbsql package and connect to a database
load fbsql.dll
sql connect 192.168.3.8 root ""
sql selectdb test

# retrieve a result set as a list of records, each list is a sub-list of all fields
set data [sql "SELECT BRANCH_ID, NAME FROM BRANCH ORDER BY NAME"]

# process a result set, one record at a time - method #1
foreach row [sql "SELECT BRANCH_ID, NAME FROM BRANCH ORDER BY NAME"] {
	set id [lindex $row 0]
	set name [lindex $row 1]
	puts "id = $id, name = $name"
}

# process a result set, one record at a time - method #1
sql startquery "SELECT BRANCH_ID, NAME FROM BRANCH ORDER BY NAME" -array branch
while {[sql fetchrow] != ""} {
	puts "id = $branch(BRANCH_ID), name = $branch(NAME)"
}
sql endquery

Notes

The main differences with this extension and the others can be summarised as follows;

Download

Download the source or DLL files as required. (you may need to right click to save the files)

  1. fbsql.c (21k), this file should also compile on Unix platforms with some minor modifications.
  2. fbsql.dll (26k), this DLL is built with stubs and should work on all Tcl 8.x versions.
  3. libmysql.dll (210k), this DLL is also required, download if you don't have it already. Copy it to same directory as fbsql.dll.
  4. Makefile, use this makefile for building on Unix platforms, see Build notes below.
  5. fbsql_solaris.tar.gz, download this for Solaris 8, includes source, makefile & compiled binary.
    Note: You may need to manually edit the Solaris Makefile.
    Note: Don't forget to enhance your LD_LIBRARY_PATH with mysql-lib-home before testing.
    Note: This file was provided by bossung@danet.de.

Build Notes

Windows

See readme.txt, this file contains build information for windows/mingw. Provided by Eckhard Arnold.

Unix

Create a new directory and save fbsql.c & Makefile. Typing make should be enough.

The above will work but assumes that you have already installed the mysql development libraries and that the files will be found in the include & lib directories specified in the Makefile - you may need to manually edit this for your purposes.

Once you have built fbsql.so you can include it in your tcl programs via load ./fbsql.so.

Author

Written by Peter Campbell for the FastBase Development Company Ltd.

License

Copyright (c) 2003, Peter Campbell Software Ltd.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Change History