sqlrelay

http://sqlrelay.sourceforge.net/index.html

It has a native TCL API and supports most popular databases.

One problem: It doesn't have production ready support to run against databases on Windows, but for the lucky people who use Linux/Unix, it seems to be an excellent solution, while TDBC is being developed.

The TCL part of the db connection will work just fine on Windows connecting to sqlrelay running on Linux/Unix (which, in turn, can connect to the database running on Windows :) ). What it doesn't have is production ready support (according to developers) for sqlrelay running on Windows.


bjdev - 2021-09-17 08:22:42

I've spent some weeks testing Sqlrelay. Some parts of the API don't work (for example proc getColumnIsPrimaryKeyByIndex {col} , proc getColumnIsPartOfKeyByIndex {col} ). I sent multiple emails to the support address advertised on the website, but didn't get a response to any of my queries (perhaps the developer has too much on).

I also tried the equivalent calls in PHP and Python and they didn't work either. Which at least shows that it isn't just the Tcl API.

Still, in my testing so far, most of it is working. One of the things that wasn't clear (to me) from the documentation is that calls like proc getTableList {wild} and proc getColumnList {table wild} return a result set over which one must iterate. The wildcard char is SQL's "%" character.


bjdev - 2021-09-17 09:33:03

Another part of the Tcl API that doesn't work is the debug commands, for example, proc debugOn {} is supposed to send debug info to stdout. To get some debug info one can prepend "-- debug\n" to a sql statement before executing the query. However, debugOn is supposed to enable debugging at the connection level, not just at the cursor level.

Below is the kind of information this cursor-level debug returns. In the case below "80706" appears to be the cursor ID, columns "id" and "ts" make up the composite primary key. I don't think the PK can be deduced from this information (this is a Postgres database).

"80706"."ts","20", 8 (0,0) NOT NULL "80706"."msg","114", 0 (0,0) NOT NULL "80706"."id","20", 8 (0,0) NOT NULL "80706"."doy","21", 2 (0,0) NOT NULL "80706"."user_msg_seq","23", 4 (0,0) NOT NULL

A call to getColumnInfo doesn't affect this "--debug" info. A call to dontGetColumnInfo causes the connection to hang. A call to getColumnInfo doesn't appear to do anything to enable getColumnIsPrimaryKey.

It's a pity. If these things worked it would allow one to build Tcl calls to query/update a database by inspection of the database structure of any of the many supported databases of Sqlrelay in what should be a db-independent manner.