| Author |
Message |
craftybytes

Joined: 17 Nov 2006 Posts: 298 Location: QLD AUSTRALIA
|
Posted: Tue 11 Dec 2007, 23:11 Post_subject:
SQlite3 database prog in Puppy..? Sub_title: How to 'set up data' in SQlite3..? |
|
.
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..
In MySQL (log on as root) - it would be something like:
| Code: | su mysql
mysql_install_db |
And in PosgreSQL:
| Code: | 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: | | /usr/bin/mysqld_safe & |
And PostgreSQL: (log in as postgres)
| Code: | | /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.
.
_________________ 3 x boot:- ASROCK VIA 'all-in-one' m/b; AMD Duron 1.8Ghz+; 1.0GB RAM; 20GB hdd (WinXP Pro); 80GB hdd (MEPIS 3.4-3/Puppy v2.15CE Frugal); 1GB USB pendrive (Puppy 2.15CE Frugal); CD/DVDRW; 17" LCD monitor; HSF 56k modem... MEPIS is great.. Puppy ROCKS..
|
|
Back to top
|
|
 |
Ian
Official Dog Handler

Joined: 04 May 2005 Posts: 1237 Location: Queensland
|
Posted: Wed 12 Dec 2007, 05:31 Post_subject:
|
|
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.
|
|
Back to top
|
|
 |
craftybytes

Joined: 17 Nov 2006 Posts: 298 Location: QLD AUSTRALIA
|
Posted: Wed 12 Dec 2007, 20:35 Post_subject:
|
|
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..
So to try and sort it - I thought of asking on this forum for possible guidance..
Thanks for any help..
crafty.
.
_________________ 3 x boot:- ASROCK VIA 'all-in-one' m/b; AMD Duron 1.8Ghz+; 1.0GB RAM; 20GB hdd (WinXP Pro); 80GB hdd (MEPIS 3.4-3/Puppy v2.15CE Frugal); 1GB USB pendrive (Puppy 2.15CE Frugal); CD/DVDRW; 17" LCD monitor; HSF 56k modem... MEPIS is great.. Puppy ROCKS..
|
|
Back to top
|
|
 |
Ian
Official Dog Handler

Joined: 04 May 2005 Posts: 1237 Location: Queensland
|
Posted: Wed 12 Dec 2007, 21:37 Post_subject:
|
|
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.
| Description |
|

Download |
| Filename |
sqlite.tar.gz |
| Filesize |
2.1 KB |
| Downloaded |
450 Time(s) |
|
|
Back to top
|
|
 |
craftybytes

Joined: 17 Nov 2006 Posts: 298 Location: QLD AUSTRALIA
|
Posted: Thu 13 Dec 2007, 20:12 Post_subject:
|
|
Thanks Ian..
I don't know about 'great minds' - I'm certain that mine is still trying to remember where it was yesterday..(ha..ha..ha..)..
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'..
Anyway - will look at what you've put in the attachment and see if it will be helpful..
TIA..
crafty.
.
_________________ 3 x boot:- ASROCK VIA 'all-in-one' m/b; AMD Duron 1.8Ghz+; 1.0GB RAM; 20GB hdd (WinXP Pro); 80GB hdd (MEPIS 3.4-3/Puppy v2.15CE Frugal); 1GB USB pendrive (Puppy 2.15CE Frugal); CD/DVDRW; 17" LCD monitor; HSF 56k modem... MEPIS is great.. Puppy ROCKS..
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 13642 Location: Karlsruhe, Germany
|
Posted: Thu 13 Dec 2007, 20:51 Post_subject:
|
|
| Quote: | | (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
Edited_time_total
|
|
Back to top
|
|
 |
MU

Joined: 24 Aug 2005 Posts: 13642 Location: Karlsruhe, Germany
|
Posted: Thu 13 Dec 2007, 21:25 Post_subject:
|
|
| Code: | 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: | 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):
| Quote: | {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/readme_sqlite_tutorial.html
Mark
|
|
Back to top
|
|
 |
2byte
Joined: 09 Oct 2006 Posts: 356
|
Posted: Sat 15 Dec 2007, 17:23 Post_subject:
|
|
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/tksqlite-0.5.6-linux-ix86-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
|
|
Back to top
|
|
 |
craftybytes

Joined: 17 Nov 2006 Posts: 298 Location: QLD AUSTRALIA
|
Posted: Sat 15 Dec 2007, 21:17 Post_subject:
|
|
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..
Anyway - will see what develops..
crafty.
.
_________________ 3 x boot:- ASROCK VIA 'all-in-one' m/b; AMD Duron 1.8Ghz+; 1.0GB RAM; 20GB hdd (WinXP Pro); 80GB hdd (MEPIS 3.4-3/Puppy v2.15CE Frugal); 1GB USB pendrive (Puppy 2.15CE Frugal); CD/DVDRW; 17" LCD monitor; HSF 56k modem... MEPIS is great.. Puppy ROCKS..
|
|
Back to top
|
|
 |
muggins
Joined: 20 Jan 2006 Posts: 6663 Location: lisbon
|
Posted: Sat 15 Dec 2007, 23:53 Post_subject:
|
|
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.
|
|
Back to top
|
|
 |
2byte
Joined: 09 Oct 2006 Posts: 356
|
Posted: Sun 16 Dec 2007, 00:58 Post_subject:
|
|
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.
|
|
Back to top
|
|
 |
Ian
Official Dog Handler

Joined: 04 May 2005 Posts: 1237 Location: Queensland
|
Posted: Sun 16 Dec 2007, 17:52 Post_subject:
|
|
Puppy 3.0.1 still has tclsh & wish, Puppy 4.0 has them removed.
|
|
Back to top
|
|
 |
craftybytes

Joined: 17 Nov 2006 Posts: 298 Location: QLD AUSTRALIA
|
Posted: Sun 16 Dec 2007, 21:45 Post_subject:
|
|
.
Thanks all for the great help..
Looks like tksqlite is the way to go..
Much appreciated..
Cheers.
crafty.
.
_________________ 3 x boot:- ASROCK VIA 'all-in-one' m/b; AMD Duron 1.8Ghz+; 1.0GB RAM; 20GB hdd (WinXP Pro); 80GB hdd (MEPIS 3.4-3/Puppy v2.15CE Frugal); 1GB USB pendrive (Puppy 2.15CE Frugal); CD/DVDRW; 17" LCD monitor; HSF 56k modem... MEPIS is great.. Puppy ROCKS..
|
|
Back to top
|
|
 |
|