newbie question - using eTcl and sqlite3 
Author Message
 newbie question - using eTcl and sqlite3

hello,

I am completely new to this, but my understanding of eTcl is that it
includes sqlite3. I just can't figure out how to go about actually
using this feature. Do I need to load a .dll or anything?
[info loaded] seems to include sqlite3, but the commands sqlite and
sqlite3 are invalid.

on my desktop, using etcl-8.4.12-pl16-win32, I can use this command
load tclsqlite3.dll Sqlite3
sqlite3 db test.db
and then the database is available as db.

this same code, using etcl-8.4.12-pl16-ppc-arm.exe on windowsCE 4.2,
generates "couldn't load library 'tclsqlite3.dll': invalid argument
while executing 'load tclsqlite3.dll Sqlite3'"

any help would be appreciated, as I obviously am missing something
fundamental, and my many hours of online searching have been in vain.

thanks,
-ks



Sun, 28 Sep 2008 01:43:40 GMT  
 newbie question - using eTcl and sqlite3
I spent a few minutes experimenting on the PocketPC :)

2% package re sqlite3
3.3.4
3% package ifneeded sqlite3 3.3.4
load {} sqlite3
4% sqlite3
wrong # args: should be "sqlite3 HANDLE FILENAME ?MODE?"
5%

It looks as if sqlite3 is statically built-in, but a [package require]
is still necessary. After that, one can use it to his heart's delight
:-)



Sun, 28 Sep 2008 01:50:56 GMT  
 newbie question - using eTcl and sqlite3

Quote:
> hello,

> I am completely new to this, but my understanding of eTcl is that it
> includes sqlite3. I just can't figure out how to go about actually
> using this feature. Do I need to load a .dll or anything?
> [info loaded] seems to include sqlite3, but the commands sqlite and
> sqlite3 are invalid.

I plead guilty, documentation is still not there.

No matter what platform you are running eTcl on (WinCE, linux or
MacOSX), everything is statically linked inside, no external
dependencies, no dll to load. All you have to do is:

   package require sqlite3

and sqlite3 command is then evailable. While provided as a standalone
static executable, eTcl support "load", so you may still decide to load
third party extensions, but the embedded extensions (tktable, sqlite,
memchan, pixane, ....) must be loaded to normal and simple way: package
require...

Quote:
> any help would be appreciated, as I obviously am missing something
> fundamental, and my many hours of online searching have been in vain.

I plead guilty about lack of documentation again ;-)

Eric

-----
Eric Hassold
Evolane - http://www.evolane.com/



Sun, 28 Sep 2008 01:54:00 GMT  
 newbie question - using eTcl and sqlite3
wow, that worked great!
thanks for the incredibly quick reply.
I wish I had found you guys earlier :)
-ks


Sun, 28 Sep 2008 02:06:06 GMT  
 newbie question - using eTcl and sqlite3
Eric,

Thank you for your quick reply for my first question, I hope you will
have time for a follow-up :)

I am able to run a query succesfully on the desktop using eTcl and
sqlite3
However, when I copy the script and database over to the PDA (running
winCE 4.2),
I continually get (for say a query on table companies)
"Error: no such table: companies"

I can verify that the database does contain this table using
sqlite3.exe tool on the desktop.
Any ideas as to what could be causing this?

-ks

Quote:

> dependencies, no dll to load. All you have to do is:

>    package require sqlite3



Mon, 29 Sep 2008 07:47:37 GMT  
 newbie question - using eTcl and sqlite3
Hi,

Are you running latest (i.e. pl16) version of eTcl?

My first guess is that you may be trying to open a database file in some
specific directory, but you don't provide an absolute path to sqlite
command, so a new database opened (or silently created if it doesn't
already exists) in the current working directory, which is / when eTcl
starts on WinCE.

Say you put both your script and your database in a directory called
/MyApps, you should either cd that directory before calling sqlite3, or
build an absolute path for your database file from the script path.

Here is a simple test which works for me, on both hardware devices (iPaq
4155 and Qtek S100) and MS emulator. If it fails for you, let me know
and I will take care of fixing sqlite support on eTcl/WinCE ASAP.

package require sqlite3

catch {console show}
catch {wm withdraw .}

set testdirs [list]
lappend testdirs [pwd]
lappend testdirs [file dirname [file normalize [info script]]]

foreach d $testdirs {
   puts "Directory: $d"

   set dbfile [file join [pwd] sqlitetest.sqi]

   if {[file exists $dbfile]} {
     file delete $dbfile
   }
   sqlite3 db $dbfile

   db eval {CREATE TABLE customers ( name text, phone varchar )}

   db eval {INSERT INTO customers (name,phone) VALUES ('c1','555-0001')}
   db eval {INSERT INTO customers (name,phone) VALUES ('c2','555-0002')}
   db eval {INSERT INTO customers (name,phone) VALUES ('c3','555-0003')}
   db eval {INSERT INTO customers (name,phone) VALUES ('c4','555-0004')}

   set res [db eval {SELECT * FROM customers}]
   foreach {name phone} $res {
     puts "$name : $phone"
   }

   db close
   file delete $dbfile

Quote:
}

Regards,

Eric

-----
Eric Hassold
Evolane - http://www.evolane.com/



Mon, 29 Sep 2008 11:15:18 GMT  
 newbie question - using eTcl and sqlite3
eric,

thanks again for the help.
The path was definitely the problem. I didn't realize that eTcl starts
in "/" on winCE, but in the current directory of the script on
windows2k. So naturally, the DB was created for me, but not reading the
one I had installed :)

I'm now using (from your example):
set currentdir [file dirname [file normalize [info script]]]
set dbfile [file join $currentdir small.db]
sqlite3 db $dbfile;

and it works great.Thanks for the tips and the patience!
-ks



Sat, 04 Oct 2008 06:32:26 GMT  
 newbie question - using eTcl and sqlite3
well, that went well. I must say I'm really impressed by the
performance of both sqlite and eTcl. I now have a simple app that
queries on a 20mb database with 390k records in about 3ms!

I wanted to thank you for your creation and support of eTcl, it was
very easy to use and once I got the problems I had above :)

My last question on this topic is in regard to compiling an executable.
Is it possible to compile an eTcl script into a standalone app for
windows and/or windowsCE? Is there a specific tool to accomplish this,
or can I use any tcl compiler like tclkit?

thanks for all the help,
-ks



Mon, 06 Oct 2008 06:06:32 GMT  
 newbie question - using eTcl and sqlite3
krsz wrote :

Quote:
> well, that went well. I must say I'm really impressed by the
> performance of both sqlite and eTcl. I now have a simple app that
> queries on a 20mb database with 390k records in about 3ms!

> I wanted to thank you for your creation and support of eTcl, it was
> very easy to use and once I got the problems I had above :)

Thanks. User feedbacks are always a great motivation.

Quote:
> My last question on this topic is in regard to compiling an executable.
> Is it possible to compile an eTcl script into a standalone app for
> windows and/or windowsCE? Is there a specific tool to accomplish this,
> or can I use any tcl compiler like tclkit?

Everything is there to do so (VFS, ...) and easy to do. But actually,
there is some kind of "license issue". More exactly, since eTcl for
Windows Mobile is pretty young, we still want final users to know what
they are using and from who, so we get valuable feedbacks from them.
Please see License file for condition (which are just similar to
ActiveTcl ones). For your own usage, you can still put everything into a
ZIP file, which will be automatically mounted when eTcl starts. Together
with etclrc.tcl file, this will allow everything to be packaged into 3
files.

If you really need to package everything into a single executable, for
commercial usage or redistribution, please contact us directly. BTW,
linking a specific eTcl version, with only those packages you actually
need, will also allow to generate a much smaller executable (starting
from 1Mb).

Regards,

Eric

-----
Eric Hassold
Evolane - http://www.evolane.com/



Mon, 06 Oct 2008 07:31:45 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. using sqlite3 to implement a virtual filesystem

2. Newbie Question (Was: Newbie Question...)

3. Newbie question on using System() and Awk

4. C4 Newbie Question - Using Functions Keys

5. A newbie question for using sort

6. Newbie here: Question on using function/subroutine

7. Newbie Question - Using FORTRAN for traffic microsimulation

8. Using IMSL: IVPAK and IVPRK (newbie question)

9. newbie question: using Python to coordinate C++ program and use gnuplot

10. newbie question: profiling a fortran program using a share library

11. TCL Newbie Question: using variables to reference variables

12. NEWBIE QUESTION: telnetting to a port number using spawn inside a procedure

 

 
Powered by phpBB® Forum Software