PDA

View Full Version : Database module?



jjcmmgb
16-05-2011, 11:37
Hi there,
I recently installed ThinBasic in my computer so I'm testing several functionalities and I have to say that I'm really astonished with the capabilities of ThinBasic :-)
However I miss more clarity on Database management on this great product.
Looking at the on-line help I see that are some pending non documented modules, among them one related to Database functions7214
Are those functions already available in current production ThinBasic version (not the beta one)
If so, how can I use them? (which is the module I should include in my projects)
When do you expect to have them documented? I need more help on that :-)
thanks a lot

ErosOlmi
16-05-2011, 12:21
Hi jjcmmgb and wellcome to thinBasic community forum.

Database functionalities made in that way has been discontinued in favor of direct ODBC connections. Please check \thinBasic\SampleScripts\ODBC\ for few examples.

Native ODBC connection is possible thanks to a wrapper José Roca has developed. Is quite vast at first but once you get used it you will find that is not that complex.

Finally: honestly I would like to have more weapons in thinBasic arsenal working with database like native MySql and native SqLite or full ADO wrapper. But this will come in future if there will be real interest.

Ciao
Eros

PS: please use thinBasic Beta 1.8.7.0 (http://www.thinbasic.com/community/showthread.php?11148-thinBasic-Beta-1.8.7.0). It is much better and even if in beta it is quite stable.

John Spikowski
17-05-2011, 05:54
I thought thinBasic was a conglomeration of modules tightly coupled to the core thinBasic runtime. If this is the case, I would hope someone would help the project out with a MySQL extension module.

Here is the ScriptBasic MySQL (http://files.allbasic.info/ScriptBasic/interface.c.txt) extension module C interface source. Maybe it could be the basis for a thinBasic version. Here is the documentation (http://www.scriptbasic.org/docs/mysql/mod_mysql_toc.html) for the for the MySQL extension module.

I have scripted a SQLite3 proof of concept but an extension module using the same SB syntax as the MySQL module still needs to be done.



' SQLite3 Demo Script

DECLARE SUB DLL ALIAS "_gtk" LIB "gtk-server"
DECLARE SUB VARPTR ALIAS "varptr" LIB "gtk-server"

DLL("gtk_server_require libsqlite3.so")

DLL("gtk_server_define sqlite3_open NONE INT 2 STRING LONG")
DLL("gtk_server_define sqlite3_exec NONE INT 5 LONG STRING INT NULL PTR_STRING")
DLL("gtk_server_define sqlite3_prepare_v2 NONE INT 5 LONG STRING INT PTR_LONG NULL")
DLL("gtk_server_define sqlite3_step NONE INT 1 LONG")
DLL("gtk_server_define sqlite3_column_text NONE STRING 2 LONG INT")
DLL("gtk_server_define sqlite3_close NONE INT 1 LONG")

CONST SQLITE_ROW = 100
db = 0
dberr = 0
stmt = 0

DLL("sqlite3_open \"testsql\" " & VARPTR(db))
DLL("sqlite3_exec " & db & " \"CREATE TABLE demo(someval INTEGER, sometxt TEXT);\" 0 0 " & VARPTR(dberr))
DLL("sqlite3_exec " & db & " \"INSERT INTO demo VALUES (123, 'Hello');\" 0 0 " & VARPTR(dberr))
DLL("sqlite3_exec " & db & " \"INSERT INTO demo VALUES (234, 'cruel');\" 0 0 " & VARPTR(dberr))
DLL("sqlite3_exec " & db & " \"INSERT INTO demo VALUES (345, 'world');\" 0 0 " & VARPTR(dberr))
result = DLL("sqlite3_prepare_v2 " & db & " \"SELECT * FROM demo;\" -1 " & VARPTR(stmt) & " 0")
SPLIT result BY " " TO ok, stmt

WHILE DLL("sqlite3_step " & stmt) = SQLITE_ROW
PRINT DLL("sqlite3_column_text " & stmt & " " & 0) & " - " & DLL("sqlite3_column_text " & stmt & " " & 1),"\n"
WEND

DLL("sqlite3_close " & db)
jrs@Laptop:~/SB/test$ scriba sqlite3.sb
123 - Hello
234 - cruel
345 - world
jrs@Laptop:~/SB/test$

ErosOlmi
17-05-2011, 07:21
We (I and some colleagues of mine like Simone) use thinBasic at company to perform many transformation operations on data. We mainly use MSSQL 2008 to perform in/out data in many different situations all using ODBC.

Some examples we use thinBasic for:

export invoicing data and send them to customers (we have 5000 customers and we produce about 6000 invoices for something like 250000 document lines per month)
import orders from 3rd party sales automation software (more than 15000 lines per day)
nigh update some customers and articles data


So, whatever database that can be managed by an ODBC can be handled with thinBasic.

That said, I feel thinBasic miss some kind of personal or single project DB handling like SQLite. It should be not so difficult to add a module to handle it. When I will finish this beta testing run (see support area (http://www.thinbasic.com/community/project.php)) I will think about that. In the meantime if you need something, just ask or add a request in support area (I work that way) so everyone can follow.

Ciao
Eros

JohnP
17-05-2011, 23:14
[QUOTE=ErosOlmi;83343]
Finally: honestly I would like to have more weapons in thinBasic arsenal working with database like native MySql and native SqLite or full ADO wrapper. But this will come in future if there will be real interest.

Hi Eros,
I would very much like to have a thinBasic module working natively with mySQL.
But unfortunately I don't have the skills to write it myself.
I use thinBasic with ODBC and mySQL to download and build a database of UK horse-racing results, on a daily basis.
I intend to build a thinBasic front end to mySQL to query the database, looking for useful patterns for betting.

I would like to add my congratulations on the excellent work you have done in writing such a speedy and reliable thinBasic Language. It's a real pleasure to use.

JohnP