Page 1 of 1

SQlite3 database prog in Puppy..?

Posted: Wed 12 Dec 2007, 03:11
by craftybytes
.
Am looking at using Puppy's SQlite3 database for a small project but am stumped at the code for how to set up for data in the database.. :oops:

In MySQL (log on as root) - it would be something like:

Code: Select all

su mysql
mysql_install_db
And in PosgreSQL:

Code: Select all

useradd -d /home/postgres postgres
mkdir /home/postgres
chown postgres home/postgres
mkdir /usr/local/pgsql/data
chown postgres /usr/local/pgsql/data
su postgres
/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
To log in to the database:

MySQL: (log in as mysql)

Code: Select all

/usr/bin/mysqld_safe &
And PostgreSQL: (log in as postgres)

Code: Select all

/usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data >-/logfile 2>&1 &
So how to do this in SQlite3 - please..? :)

Any help would be much appreciated..

crafty.
.

Posted: Wed 12 Dec 2007, 09:31
by Ian
What are you trying to set up exactly.

I can give you the code to set up databases & tables as I used Sqlite originaly in Puppy Money.

Posted: Thu 13 Dec 2007, 00:35
by craftybytes
Hi Ian,

Actually what I'm trying to suss out is - I'm looking at Gambas to wack up a simple GUI for access to an SQlite3 database - have examples for MySQL & PostgreSQL - but none for SQlite.. :cry:

So to try and sort it - I thought of asking on this forum for possible guidance.. :wink:

Thanks for any help..

crafty.
.

Posted: Thu 13 Dec 2007, 01:37
by Ian
All great minds think alike. I am trying to do the same with sqlite using tcl/TK, Xlibs and Perl/TK for a start.

The attachment contains the basic commands.

Posted: Fri 14 Dec 2007, 00:12
by craftybytes
Thanks Ian.. :wink:

I don't know about 'great minds' - I'm certain that mine is still trying to remember where it was yesterday..(ha..ha..ha..).. :lol:

With using Gambas to make the GUI - I wanted to keep possible dependencies to as low as necessary - thus just Gambas - (hopefully it can use Puppy's in-built Basic as a base to work with..) - I see you've got 'tcl/TK, Xlibs and Perl/TK'.. :roll:

Anyway - will look at what you've put in the attachment and see if it will be helpful.. 8)

TIA..

crafty.
.

Posted: Fri 14 Dec 2007, 00:51
by MU
(hopefully it can use Puppy's in-built Basic as a base to work with..)
No, certainly 100% incompatible.
Gambas is a QT application (KDE base-library).
Puppybasic = commandline only.
GtkBasic = Puppybasic with Gtk2 bindings.

I had no closer look at Gambas yet, but could imagine that it uses a completely different model concerning the mainloop.
GtkBasic runs 2 parallel threads, that just share a memory-segment, but apart from that are 2 different applications (the Gtk C mainloop and the Basic interpreter).
This is even very different to wxBasic, that Puppybasic derives from.
That used a "blocking" model without threads, where the grafical interface was a "part" of the interpreter.

The approach GtkBasic uses has some advantages, but makes it incompatible with others.

For GtkBasic, you can use Glade to create the grafical interface.
Install Glade with Petget, then you can start it from the GtkBasic-Ide for your current project :)

Mark

Posted: Fri 14 Dec 2007, 01:25
by MU

Code: Select all

xwin_system(" sqlite3 MUtest.db  \"create table t1 (t1key INTEGER PRIMARY KEY,data TEXT,num double,timeEnter DATE);\"")

xwin_system(" sqlite3 MUtest.db \"insert into t1 (data,num) values ('This is sample data',3);\"")
result = xwin_system(" sqlite3 MUtest.db \"select * from t1\";")

print result
result is a GtkBasic list, so you now could iterate through it with

Code: Select all

for each theline in result
...
next
The ... had to be replaced with things that make sense, e.g. you could add these values to a clist to display them in a window (see clist demo).

The first code above will print this if run as a GtkBasic program from a consolewindow or the Ide (that opens a consolewindow for debugging-purposes):
{0:"1|This is sample data|3.0|
", 1:"2|This is sample data|3.0|
"}
I ran the simple program twice, so it shows 2 lines.

I have no experience with sqlite, just grabbed some commands from here:
http://souptonuts.sourceforge.net/readm ... orial.html

Mark

Posted: Sat 15 Dec 2007, 21:23
by 2byte
Hi crafty,

May I suggest TKSqlite for building the database? http://reddog.s35.xrea.com/wiki/TkSQLite.html
I use the single file binary, it has no other dependencies. http://reddog.s35.xrea.com/software/tks ... bin.tar.gz

Gambas2 has two decent sqlite3 database examples, PictureDatabase and Database. The first one is simple and might be adaptable for your needs. The second one uses data-bound gtk widgets if you like that sort of thing.

Vern

Posted: Sun 16 Dec 2007, 01:17
by craftybytes
Thanks guys - will look into it..!!

2byte -

Am d'ling the TKSqlite binary at the moment - will try it - BUT for my small project was trying to keep it as simple as I could for the GUI part - thus hoping that Gambas2 would make an 'stand-alone' executable GUI to use with SQlite3 databases.. :?

As BK has removed TK/Tcl from the version 3.xx/4.xx Puppies (can be put in as dotpets however) - was hoping to come up with a more general GUI that would work in v2.xx/3.xx & v4.xx puppies (if this is possible).. :?:

I may have to just use the QT GUI tools to do what I want.. :roll:

Anyway - will see what develops.. :wink:

crafty.
.

Posted: Sun 16 Dec 2007, 03:53
by muggins
Crafty,

I don't know if this is relevant to your quest, but the tksqlite binary, recommended by 2byte, doesn't require an external tcl/tk environment, as it contains it's own internal tcl/tk structure, plus sqlite, plus any tcl files required for it to run, so it should work on any puppy version.

Posted: Sun 16 Dec 2007, 04:58
by 2byte
Right, tksqlite makes it super easy to build and test the database, tables, and sql that you might need for your program. You can do it all with gambas if you prefer. Tksqlite will output the sql used for the create table statements too, and that can be real handy if you want to recreate the database with your gambas program code.

Posted: Sun 16 Dec 2007, 21:52
by Ian
Puppy 3.0.1 still has tclsh & wish, Puppy 4.0 has them removed.

Posted: Mon 17 Dec 2007, 01:45
by craftybytes
.
Thanks all for the great help.. :D

Looks like tksqlite is the way to go.. :lol:

Much appreciated.. :o

Cheers.

crafty.
.

Posted: Thu 27 Sep 2018, 23:58
by musher0
Hi, DB fans!

First do a thorough vacuuming on this 11 years old thread! ;) :lol:
But since this sqlite3 thread already existed, there was no need for me
to create a new one!

Just out, version 3.25.2 of sqlite (which includes the sqlite3 executable
that all new Puppies have), available from
https://www.sqlite.org/download.html

I tested briefly the Linux ready-made executables at
https://www.sqlite.org/2018/sqlite-tool ... 250200.zip
and they work fine on my xenialPup-7.0.6. YMMV.

Simply unzip in /usr/bin and make them executable.

Essential docs -- if you are serious about working with sqlite3 -- are
available on the same page.

BFN.