Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Database Help

0 views
Skip to first unread message

Matt

unread,
Apr 16, 2003, 2:08:08 PM4/16/03
to
I am new to tcl and am looking for a way to connect to a SQL Server 2000
database from a Linux machine using tcl. Is there a tutorial or any
examples online that might help me out.

Thanks for any help,
Matt


Michael Schlenker

unread,
Apr 16, 2003, 2:36:30 PM4/16/03
to
Matt wrote:
> I am new to tcl and am looking for a way to connect to a SQL Server 2000
> database from a Linux machine using tcl. Is there a tutorial or any
> examples online that might help me out.
>
tclodbc should be what you need.

http://wiki.tcl.tk/tclodbc

Michael Schlenker


Matt

unread,
Apr 16, 2003, 3:49:16 PM4/16/03
to
"Michael Schlenker" <sch...@uni-oldenburg.de> wrote in message
news:b7k7lj$1oo4r$1...@ID-102549.news.dfncis.de...

Thanks for the quick reply. I gave tclodbc a try, but I am running into
problems on the configure. I have followed the directions in the link you
provided, to download the tclodbc tar.gz and I have tried the config
directory from both oratcl3.3 and the link given on that page. I run
automake, then ./configure and it errors out on this line:

configure: error: cannot run /bin/sh config/config.sub

I look in the config directory and there is no config.sub file. Anyone else
have any problems with this?

Thanks again for the help,
Matt


Matt

unread,
Apr 16, 2003, 5:47:05 PM4/16/03
to
"Matt" <MattnoChil...@msn.com> wrote in message
news:b7kc3t$1uurl$1...@ID-127463.news.dfncis.de...


Ok, I think I finally got tclodbc installed. I stole a config.sub and
config.guess from somewhere else on my machine, apparently all it does it
figure out what kind of system you have. I was able to make and make
install, everything seemed to go fine. However, when I go into tclsh and
run my database command I get the following:

%database connect db "DRIVER=SQL Server;SERVER=servername;DBQ=mydb"
invalid command name "database"

Is there something else I need to do so that I can use the database command?
(forgive any dumb questions)

Again, thanks for the help, and sorry for continuing to bother you all with
this.
Thanks,
Matt


Matt

unread,
Apr 16, 2003, 6:36:29 PM4/16/03
to

"Matt" <MattnoChil...@msn.com> wrote in message
news:b7kj0r$20vsn$1...@ID-127463.news.dfncis.de...

Ok, final question I promise. I found my problem, must have skipped over
that part of the docs. (RTFM) I am doing the following:

% package require tclodbc
can't find package tclodbc

Do I need to be in a certain directory to run this command. This is driving
me crazy, but I think I am so close. Any help would be appreciated.

Thanks,
Matt


Michael A. Cleverly

unread,
Apr 16, 2003, 7:44:39 PM4/16/03
to
On Wed, 16 Apr 2003, Matt wrote:

> Ok, final question I promise. I found my problem, must have skipped over
> that part of the docs. (RTFM) I am doing the following:
>
> % package require tclodbc
> can't find package tclodbc
>
> Do I need to be in a certain directory to run this command. This is driving
> me crazy, but I think I am so close. Any help would be appreciated.

tclodbc's pkgIndex.tcl file needs to be in a direcotry (or an immediate
subdirectory of one) listed in $auto_path.

If the [make install] stashed the tclodbc package under /usr/local/lib,
say, and your tclsh/wish's auto_path doesn't include /usr/local/lib, it
won't be able to find it. In that case, do one of:

1) In your shell before starting tclsh/wish, set the environment
variable TCLLIBPATH to /the/path/to/your/install/directory

2) Move the tclodbc package to a subdirectory of a directory already
listed in $auto_path

3) In your script before you do a [package require] lappend /the/path
to auto_path

Michael

Matt

unread,
Apr 16, 2003, 8:04:10 PM4/16/03
to

"Michael A. Cleverly" <mic...@cleverly.com> wrote in message
news:Pine.LNX.4.44.030416...@gibraltar.cleverly.com...

Thanks Michael for the help. I believe I have the package installed now, I
did the following:

% lappend auto_path /usr/local/lib
/usr/share/tcl8.3 /usr/share /usr/lib /usr/local/lib

% package require tclodbc
2.2

%database db "DRIVER=SQL Server;SERVER=server;DBQ=mydb"
invalid command name "database"

As you can see it looks like the package is (added, installed?), however I
still get the invalid command name. A little googling found that someone
else who had the same problem had to use the following command after package
require:

% load /usr/local/lib/libtclodbc2.2.so

But adding that to my script cause an error:

couldn't load file ... undefined symbol _ZTVN10_cxxabiv117__class_type_infoE

Everytime I think I've almost got it, I run into something else.
Thanks again for all your help,
Matt


Michael A. Cleverly

unread,
Apr 16, 2003, 8:27:13 PM4/16/03
to
On Wed, 16 Apr 2003, Matt wrote:

> I believe I have the package installed now, I did the following:
>
> % lappend auto_path /usr/local/lib
> /usr/share/tcl8.3 /usr/share /usr/lib /usr/local/lib
>
> % package require tclodbc
> 2.2
>
> %database db "DRIVER=SQL Server;SERVER=server;DBQ=mydb"
> invalid command name "database"

That's odd. I haven't had much occassion to use tclodbc myself (the few
times I have were on Windows). Out of curiosity, what does [info loaded]
show, both before & after the [package require tclodbc] ?



> As you can see it looks like the package is (added, installed?), however I
> still get the invalid command name. A little googling found that someone
> else who had the same problem had to use the following command after package
> require:
>
> % load /usr/local/lib/libtclodbc2.2.so
>
> But adding that to my script cause an error:
>
> couldn't load file ... undefined symbol _ZTVN10_cxxabiv117__class_type_infoE
>
> Everytime I think I've almost got it, I run into something else.
> Thanks again for all your help,

I think I'll go download the tclodbc & try and compile it myself...

Michael

Matt

unread,
Apr 16, 2003, 8:39:11 PM4/16/03
to

<snip>

>
> That's odd. I haven't had much occassion to use tclodbc myself (the few
> times I have were on Windows). Out of curiosity, what does [info loaded]
> show, both before & after the [package require tclodbc] ?

Here is what it looks like when I type the following commands:

$ tclsh

% info loaded
% package names
Tcl


% package require tclodbc
2.2

% info loaded
%package names
http Expect tcltest opt msgcat Tkx Tclx tclodbc Tcl

The info loaded doesn't return anything. However, the package names, which
I understand tells which packages are have been loaded, shows several more.
I am so new at tcl, I really don't know what all this even means. I work
for a school district and we are trying to use Expect to automate a telnet
session that keeps student information. We use MS SQL Server, and I was
hoping to get this working so I could pull the info directly out of SQL
Server and send it to the telnet session with Expect. This is the last
hurdle, if I can get my tcl scripts to talk with the SQL server, I should be
able to get it all working.

<snip>


>
> I think I'll go download the tclodbc & try and compile it myself...
>
> Michael
>

Thanks again for all your help,

Matt


Michael A. Cleverly

unread,
Apr 16, 2003, 11:12:33 PM4/16/03
to
On Wed, 16 Apr 2003, Matt wrote:

> The info loaded doesn't return anything.

Then the extension isn't loaded.

> > I think I'll go download the tclodbc & try and compile it myself...
>

> Thanks again for all your help,
> Matt

The unix tarball on SourceForge appears to be broken (it seems to be
missing some of the config files). When I did a CVS checkout I was able
to get it to compile (using UnixODBC libraries). I'll tar up the cvs
checkout and send it to you.

What Linux distribution are you using BTW?

Michael

Matt

unread,
Apr 16, 2003, 11:38:42 PM4/16/03
to
> The unix tarball on SourceForge appears to be broken (it seems to be
> missing some of the config files). When I did a CVS checkout I was able
> to get it to compile (using UnixODBC libraries). I'll tar up the cvs
> checkout and send it to you.
>
> What Linux distribution are you using BTW?
>
> Michael
>

I downloaded the 2.2.1 tar.gz they had. I also compiled using the config
folder seperate from the link on this site (posted earlier in this thread:
http://wiki.tcl.tk/tclodbc, the other option was to use the config folder
from oratcl3.3). I also used the unixODBC libs. I did not get the CVS,
though. I am using RedHat, I have tried it on both 8.0 and 9, with the same
results. Thanks for all your help on this, I really, really appreciate it.

Matt


Ralf Fassel

unread,
Apr 17, 2003, 4:47:14 AM4/17/03
to
* "Matt" <MattnoChi...@msn.com>
| [http://wiki.tcl.tk/tclodbc setup problems]

IIRC tclodbc just provides the link to some other ODBC library
(UnixODBC in your case). UnixODBC in turn has a configuration file
where the possible ODBC datasources are listed and how to access them:
typically by loading another shared library for the specific database
which should be accessed.

I got tclodbc running some time ago by first compiling the ODBC
interface for the specific database (MySQL in my case), then compiling
and configuring and testing the UNIXODBC layer (e.g. via the isql
program), then compiling tclodb.

If the UnixODBC layer works, I'd try to `load' the shared libraries
involved manually in TCL: first the ODBC-interface of your database,
then the UNIXodbc shared lib, then tclodbc. One of these should throw
the `unresolved symbol' error, and then try to figure out which other
libraries this one depends on (and why this information is not
included in the lib itself so the runtime linker/loader can do the
job).

HTH
R'

Matt

unread,
Apr 17, 2003, 2:31:05 PM4/17/03
to
"Ralf Fassel" <ral...@gmx.de> wrote in message
news:ygay929...@jupiter.akutech-local.de...

Thanks for the help. I finnaly got it going by downloading the rpm from
http://jfontain.free.fr/tclodbc-2.2.1-1.i386.rpm. It was made for RedHat
7.3 but it worked on my RH 9 machine. However, I then found out that you
have to purchase odbc drivers or an odbc bridge to get it to connect to MS
SQL Server, which cost several hundred dollars. I have decided to scrap the
whole tclodbc project and am just going to use csv files. And after all
that work....

Thanks again for everyone's help,
Matt


Jeff Godfrey

unread,
Apr 17, 2003, 2:55:36 PM4/17/03
to

"Matt" <MattnoChil...@msn.com> wrote in message
news:b7mrta$2ibt7$1...@ID-127463.news.dfncis.de...

> Thanks for the help. I finnaly got it going by downloading the rpm from
> http://jfontain.free.fr/tclodbc-2.2.1-1.i386.rpm. It was made for RedHat
> 7.3 but it worked on my RH 9 machine. However, I then found out that you
> have to purchase odbc drivers or an odbc bridge to get it to connect to MS
> SQL Server, which cost several hundred dollars. I have decided to scrap
the
> whole tclodbc project and am just going to use csv files. And after all
> that work....
>
> Thanks again for everyone's help,
> Matt


Matt,

I'm by no means an expert, but I thought there were some *free* odbc drivers
available that should do what you want. Does someone else know? Short of
that, if you are really looking at resorting to csv files for storage, have
you looked into Metakit and it's tcl binding? If not, it's *very* well
worth your time. If you're unfamiliar, you can take a look here:

http://www.equi4.com/metakit/

From the above site:

"Metakit is an efficient embedded database library with a small footprint.
It fills the gap between flat-file, relational, object-oriented, and
tree-structured databases, supporting relational joins, serialization,
nested structures, and instant schema evolution."

I've used it quite extensively on several projects from within TCL and I've
been quite pleased with the results. There is also a "metakit" mailing list
if you're interested (link at the bottom of the above site).


Jeff


Benjamin Riefenstahl

unread,
Apr 18, 2003, 7:50:23 AM4/18/03
to
Hi Matt,


"Matt" <MattnoChil...@msn.com> writes:

> However, I then found out that you have to purchase odbc drivers or
> an odbc bridge to get it to connect to MS SQL Server, which cost
> several hundred dollars.

That's the nature of ODBC. There is an ODBC driver that can connect
to MS SQL in the FreeTDS package (see http://www.freetds.org). I
haven't worked with that yet, though.


Hope this helps, benny

0 new messages