Re: [sqlite] Good Graphical Tool for 3.x

2005-03-08 Thread Detlef Groth

Sorry for the delay.

Yes it should run on linux, at least it does on my box. Could you
provide the link which setup.tcl is missing (or a screenshot from the error). I 
know those error windows
are a little bit strange ...

Or you try it from an other linux machine.  May be it is a network
issue. At best the files are on the same machine wherew you are logged in.

regards,
Detlef


>
>Hi!
>Detlef Groth wrote:
>
>>Hello,
>>
>>You can try my program dgSQLite. I recently added sqlite3 support:
>>
>>http://goblet.molgen.mpg.de/dgSQLite3.kit
>>
>>You need a tclkit runtime from:
>>
>>http://www.equi4.com/pub/tk/downloads.html
>>
>>in order to run it.
>>  
>>
>[...]
>I've tried it for Linux (Fedora Core 3) : ./tclkit-linux-x86 dgSQLite3.kit
>and a very long window opened with complains, it begins with "couldn't 
>open "setup.tcl":
>no such file" and so on.
>Does it really work on Linux?
>Igor Gorbounov


RE: [sqlite] Good Graphical Tool for 3.x

2005-03-03 Thread Detlef Groth

Hello,

You can try my program dgSQLite. I recently added sqlite3 support:

http://goblet.molgen.mpg.de/dgSQLite3.kit

You need a tclkit runtime from:

http://www.equi4.com/pub/tk/downloads.html

in order to run it.

The old version for sqlite2 is at:
http://www.microemacs.de/tcltk_dgsqlite.html

OS's supported are: Win32,Linux and OSF1. Other can be added as well
if the tclsqlite-shared lib is provided.

Please be aware that there is no warranty of any kind. Currently i
just stick with sqlite2 because my R-library still remains sqlite2 and
I can't change this.

regards,
Detlef


>
>Thanx, I tried that would last night, unfortunately the trial version is
>so crippled its worthless.
>
>>
>> The SqlitePlus Database Manager is pretty good.  Its very similar to
>> Microsoft
>> SQL Query Analyzer.  Here is the URL:
>>
>> www.sqliteplus.com
>>
>>
>> Quoting Tim McDaniel <[EMAIL PROTECTED]>:
>>
>>>


[sqlite] sqlite3.1.2: how to build libtclsqlite.so

2005-02-16 Thread Detlef Groth
   Hello,

   I am trying to build libtclsqlite.so on DEC-OSF1.

   I run
   ../configure 
   gmake 
   gmake test

   without problems

   after:

   [EMAIL PROTECTED]:/project/goblet/src/sqlite-3.1.2/build> make install
   tclsh ../sqlite/tclinstaller.tcl 3.1
   couldn't open ".libs/libtclsqlite3.so": no such file or directory
   while executing
   "open $LIBFILE"
   invoked from within
   "set in [open $LIBFILE]"
   (file "../sqlite/tclinstaller.tcl" line 23)
   *** Exit 1
   Stop.

   I checked and indeed that there is no shared lib.

   There are just:
   [EMAIL PROTECTED]:/project/goblet/src/sqlite-3.1.2/build> ls ./.libs/
   libsqlite3.a   libsqlite3.lai libtclsqlite3.la
   libsqlite3.la  libtclsqlite3.alibtclsqlite3.lai

   How to build the shared lib ?

   btw. 2.8.16 went fine. Here the so-file is build during executing
   `gmake test' although this seems to be as well a little bit tricky.

   regards,
   Detlef

-- 
Dr. Detlef Groth
Max-Planck-Institut
fuer Molekulare Genetik
Ihnestr. 63/73
D-14195 Berlin
Tel.: + 49 (0)30 - 8413 1235
Fax:  + 49 (0)30 - 8413 1128


Re: [sqlite] Compiling sqlite3.0.3 on dec-osf1 with gcc 3.04 failed

2004-08-12 Thread Detlef Groth
Hello,

I compiled the new 3.0.4 sources without any changes on OSF-1 now. No need
for the
'-DUINTPTR_TYPE=unsigned long long' flag at all.

However I am wondering that the shared lib for tcl is build only by
invoking `make test' and that this shared lib is much smaller than the
shared lib gotten with the old:

gmake target_source
cd tsrc
rm shell.c
gcc -fPIC -DNDEBUG=1 -shared *.c -o tclsqlite.so
-L/project/amphioxus/lib -I/project/amphioxus/include -L/usr/shlib
-ltcl8.4 -rpath "/usr/shlib:/project/amphioxus/lib:/usr/local/lib"

approach ?

How can I compile a smaller 2.8.15 shared tcl-lib? In 2.8.15 `make test'
makes
the static but not the dynamic library for tcl ?



regards,
Detlef

-- 
Dr. Detlef Groth
Max-Planck-Institut
fuer Molekulare Genetik
Ihnestr. 63/73
D-14195 Berlin
Tel.: + 49 30 - 8413 1235




Re: [sqlite] Compiling sqlite3.0.3 on dec-osf1 with gcc 3.04 failed

2004-08-06 Thread Detlef Groth
I added `-DUINTPTR_TYPE=u64' to the TCC line of the Makefile but it does not
help either!

[EMAIL PROTECTED]:/project/amphioxus/src/sqlite-3.0.3/build> gmake clean all
rm -f *.lo *.la *.o sqlite3 libsqlite3.la
rm -f sqlite3.h opcodes.*
rm -rf .libs .deps 
rm -f lemon lempar.c parse.* sqlite*.tar.gz
rm -f 
rm -f *.da *.bb *.bbg gmon.out
rm -f testfixture test.db
rm -rf doc
rm -f common.tcl
rm -f sqlite3.dll sqlite3.lib
sed -e s/--VERS--/`cat ../sqlite/VERSION`/ \
 ../sqlite/src/sqlite.h.in >sqlite3.h
echo '/* Automatically generated file.  Do not edit */' >opcodes.h
grep '^case OP_' ../sqlite/src/vdbe.c | \
  sed -e 's/://' | \
  awk '{printf "#define %-30s %3d\n", $2, ++cnt}' >>opcodes.h
gcc -g -O2 -o lemon ../sqlite/tool/lemon.c
cp ../sqlite/tool/lempar.c .
cp ../sqlite/src/parse.y .
./lemon parse.y
./libtool --mode=compile gcc -g -O2 -DOS_UNIX=1 -DHAVE_USLEEP=1
-DUINTPTR_TYPE=u64 -I. -I../sqlite/src -DNDEBUG -c ../sqlite/src/attach.c
 gcc -g -O2 -DOS_UNIX=1 -DHAVE_USLEEP=1 -DUINTPTR_TYPE=u64 -I.
-I../sqlite/src -DNDEBUG -c ../sqlite/src/attach.c -o attach.o
In file included from ../sqlite/src/attach.c:16:
../sqlite/src/sqliteInt.h:129: parse error before "uptr"
../sqlite/src/sqliteInt.h:129: warning: data definition has no type or
storage class
gmake: *** [attach.lo] Error 1

>Detlef Groth wrote:
>> Hello,
>> 
>> I could recently compile the sqlite2.x code without problems but now I
can't
>> compile the the 3.0.3 branch.
>> 
>> The main problem is in:
>> sqliteInt.h:129: parse error before "uptr"
>> sqliteInt.h:129: warning: data definition has no type or storage class
>> 

>Try adding '-DUINTPTR_TYPE=u64' to the compiler command line.  Please let
me know if that helps.

>-- 
>D. Richard Hipp -- [EMAIL PROTECTED] -- 704.948.4565
--
Dr. Detlef Groth 
dgroth
at
gmx.de



RE: [sqlite] Median as an aggregate function using the tcl interface

2004-06-08 Thread Detlef Groth

Hello,

After consulting the php-sources I could hack the tclsqlite.c file
myself to add aggregation capabilities to tcl, this should go into the
next release:

the diff:

2c2
< ** 2001 September 15
---
> ** 2004 June 8 added aggregate function by Dr. Detlef Groth (dgroth at gmx.de)
43a44,54
> /*
> ** New SQL aggregate functions can be created as TCL scripts.  Each such aggregate 
> function
> ** is described by an instance of the following structure.
> */
> typedef struct SqlAggrFunc SqlAggrFunc;
> struct SqlAggrFunc {
> Tcl_Interp *interp;   /* The TCL interpret to execute the function */
> char *zScriptStep;/* The script to be run foreach row*/
> char *zScriptFine;/* The script to be run at the end*/
> SqlFunc *pNext;   /* Next function on the list of them all */
> };
399a411,447
> static void tclSqlAggStep(sqlite_func *context, int argc, const char **argv){
> SqlAggrFunc *p = sqlite_user_data(context);
> Tcl_DString cmd;
> int i;
> int rc;
> int zargc , zargs;
> zargc = argc ;
> Tcl_DStringInit();
> Tcl_DStringAppend(, p->zScriptStep, -1);
> for(i=0; i<(zargc); i++){
> Tcl_DStringAppendElement(, argv[0] ? argv[i] : "");
> }
> rc = Tcl_Eval(p->interp, Tcl_DStringValue());
>   if( rc ){
> sqlite_set_result_error(context, Tcl_GetStringResult(p->interp), -1); 
>   }else{
> sqlite_set_result_string(context, Tcl_GetStringResult(p->interp), -1);
>   }
> }
> 
> /** This routine is called to evaluate an SQL aggregate implemented
> ** using TCL script.
> */
> static void tclSqlAggFine(sqlite_func *context){
> SqlAggrFunc *p = sqlite_user_data(context);
> int rc;
> Tcl_DString cmd;
> Tcl_DStringInit();
> Tcl_DStringAppend(, p->zScriptFine, -1);
> rc = Tcl_Eval(p->interp, Tcl_DStringValue());
> if( rc ){
> sqlite_set_result_error(context, Tcl_GetStringResult(p->interp), -1); 
> }else{
> sqlite_set_result_string(context, Tcl_GetStringResult(p->interp), -1);
> }
> }
> 
493c541
< "errorcode",  "eval",   "function",
---
> "errorcode",  "eval",   "function", "aggregate",
502c550
< DB_ERRORCODE, DB_EVAL,   DB_FUNCTION,
---
> DB_ERRORCODE, DB_EVAL,   DB_FUNCTION,  DB_AGGREGATE,
864a913,944
>   }
>   /*
>   ** $db aggregate NAME SCRIPTSTEP SCRIPTFINALIZE
>   **
>   ** Create a new SQL aggregate function called NAME.  Whenever that function is
>   ** called, invoke SCRIPTINIT for each row and SCRIPTFINALIZE at the end to 
> evaluate the function.
>   */
>   case DB_AGGREGATE: {
>   SqlAggrFunc *pFunc;
>   char *zName;
>   char *zScript;
>   char *zScriptFine;
>   int nScript1;
>   int nScript2;
>   if( objc!=5 ){
>   Tcl_WrongNumArgs(interp, 2, objv, "NAME SCRIPTSTEP SCRIPTFINALIZE");
>   return TCL_ERROR;
>   }
>   zName = Tcl_GetStringFromObj(objv[2], 0);
>   zScript = Tcl_GetStringFromObj(objv[3], );
>   zScriptFine = Tcl_GetStringFromObj(objv[4], );
>   pFunc = (SqlAggrFunc*)Tcl_Alloc( sizeof(*pFunc) + nScript1 +nScript2 + 1 );
>   if( pFunc==0 ) return TCL_ERROR;
>   pFunc->interp = interp;
>   pFunc->zScriptStep = (char*)[1];
>   pFunc->pNext = pDb->pFunc;
>   pFunc->zScriptFine = (char*)[2];
>   strcpy(pFunc->zScriptStep, zScript);
>   strcpy(pFunc->zScriptFine, zScriptFine);
>   sqlite_create_aggregate(pDb->db, zName, -1, tclSqlAggStep, tclSqlAggFine, 
> pFunc);
>   sqlite_function_type(pDb->db, zName, SQLITE_NUMERIC);
>   break;

Here comes an usage example in tcl:
load tclsqlite-stub-aggr.dll
sqlite sql d:/data/yaspo2004bt.sqlite
# the old function interface
sql function median Median
# the new aggregate interface
sql aggregate medianAgg MedianAggStep MedianAggFin
set l [list]
proc Median {value} {
  global l
  lappend l $value 
  # crude and slow but works
  return  [lindex [lsort -integer $l] [expr round([llength $l] / 2)]]
}
set v [lindex [sql eval "select median(Size) from tensembl"] end]
tk_messageBox -type ok -title "Info!" -message "Result: $v"
set l [list]
set v ""
proc MedianAggStep {args} {
global l
lappend l [lindex $args 0]
return 0
}
proc MedianAggFin {} {
 global l
 # this is just executed ones
 return [lindex [lsort -integer $l] [expr round([llength $l] / 2)]]
}
array unset val
sql eval "select medianAgg(Size) from tensembl" val {
  # to get the key
  set key [array names val medianA*]
  tk_messageBox -type ok -title "Info!" -message "Result Aggregate: $val($key)"
}

regards,
Detlef

-- 
Dr. Detlef Groth
Max-Planck-Institut
fuer Molekulare Genetik
Ihnestr. 63/73
D-14195 Berlin
Tel.: + 49 30 - 8413 1235

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: [Fwd: [sqlite] Median as an aggregate function using the tcl interface]

2004-06-08 Thread Detlef Groth

Thanks for your suggestion,

indeed it is called for each row. That's my problem. A better solution
which just extract the last result is:
package require sqlite

sqlite sql d:/data/yaspo2004bt.sqlite
sql function median Median
set l [list]
proc Median {value} {
  global l
  lappend l $value 
  return  [lindex [lsort -integer $l] [expr round([llength $l] / 2)]]
  # not absolute exact but just a draft
}
puts [lindex {sql eval "select median(Size) from tensembl"} end]

However I want to execute it as a true aggregate function which should
only return 1 row. I saw that this seems possible with php
(http://www.klevze.si/php_manual/function.sqlite-create-aggregate.php)

May be I must extend tclsqlite.c with an enum DB_AGGREGATE and an case
DB_AGGREGATE which adjusts this part:


// partof tclsqlite.c
case DB_FUNCTION: {
SqlFunc *pFunc;
char *zName;
char *zScript;
int nScript;
if( objc!=4 ){
  Tcl_WrongNumArgs(interp, 2, objv, "NAME SCRIPT");
  return TCL_ERROR;
}
zName = Tcl_GetStringFromObj(objv[2], 0);
zScript = Tcl_GetStringFromObj(objv[3], );
pFunc = (SqlFunc*)Tcl_Alloc( sizeof(*pFunc) + nScript + 1 );
if( pFunc==0 ) return TCL_ERROR;
pFunc->interp = interp;
pFunc->pNext = pDb->pFunc;
pFunc->zScript = (char*)[1];
strcpy(pFunc->zScript, zScript);
sqlite_create_function(pDb->db, zName, -1, tclSqlFunc, pFunc);
sqlite_function_type(pDb->db, zName, SQLITE_NUMERIC);
break;
  }

Your idea with the median is right and faster than my one but I want to
implement a true sql-solution.

Anyone with more c-knowledge than me to implement this ?


>   >Hello,
>   >
>   >Is it possible to write the median as an aggregate function using pure
>   >tcl.
>
>   No, there does not seem to be a way of specifying that a Tcl function in 
>   SQLite should be an aggregate function, not a normal one (based on a quick 
>   look through the tclsqlite.c file).
>
>   Two further comments:
>
>   1. Your Median function seems to be expecting to be called once for each 
>   row, rather than just once total (or else how will the lappend part work?)
>
>   2. Won't something like the following do what you want?
>
>   set sortedlist [lsort -integer [sql eval {select Size from tensembl}]]
>   lindex $sortedlist [expr round([llength $sortedlist] / 2)]]
>
>   Gerry
>
>

regards,
Detlef

-- 
Dr. Detlef Groth
Max-Planck-Institut
fuer Molekulare Genetik
Ihnestr. 63/73
D-14195 Berlin
Tel.: + 49 30 - 8413 1235

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[sqlite] Median as an aggregate function using the tcl interface

2004-06-07 Thread Detlef Groth

Hello,

Is it possible to write the median as an aggregate function using pure
tcl.

I did the following:

package require sqlite
sqlite sql d:/data/yaspo2004bt.sqlite
sql function median Median
set l [list]
proc Median {value} {
  global l
  lappend l $value
  # not absolute exact but just a draft
  return  [lindex [lsort -integer $l] [expr round([llength $l] / 2)]]
}
sql eval "select median(Size) from tensembl" val {set key [array names val median*] ; 
puts $val($key)}
result:

448
448
448
448
412
412
378
387
378
387
378
387
387
.
.
.
450

450 is the right result. However I get it at the very end.

And this is slow because it computes foreach row the median, I would
like only to compute it ones. For the last element! Becuase it is a
aggregate.

Any hint ?

regards,
Detlef

-- 
Dr. Detlef Groth
Max-Planck-Institut
fuer Molekulare Genetik
Ihnestr. 63/73
D-14195 Berlin
Tel.: + 49 30 - 8413 1235

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]