Scolring - Forum

Entraides et échanges autour de la technologie Scol - Informations and exchanges on the Scol technology

Vous pouvez changer la langue de l'interface une fois inscrit - You can change the language once registered

You are not logged in.

#1 20-Oct-2024 00:39:20

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,527
Website

basic sqlite question: how do you create a database with the scol api-

hello everyone

i downloaded libsqlite3.dll (the version posted to https://redmine.openspace3d.com/projects/sqllite3/files on 04/12/2013 03:02 PM, and put it in my computer's C:\Program Files\Scol Voyager  directory.

then i put the line:

plugin plugins/libsqlite3.dll

right after:

plugin plugins/ScolSQL.dll

in the Usm.ini file in the C:\Program Files\Scol Voyager

that being done, how would I  create a new database where none exists?  the example posted to :https://redmine.openspace3d.com/projects/scol/embedded/_sqliteOpenFile.html only shows how to open an existing database

thanks for your help!
-Dan

Last edited by hebdemnobad (20-Oct-2024 19:41:45)

Offline

#2 21-Oct-2024 01:09:51

hebdemnobad
Member
From: northamerica
Registered: 20-Apr-2011
Posts: 1,527
Website

Re: basic sqlite question: how do you create a database with the scol api-

this works... btw redmine says the proto of
_sqliteExec is

fun [ObjSqlite S I] I where the first I is nil

the sqlite api has changed, all you need is

fun [ObjSqlite S]

typeof mydb = ObjSqlite;;

fun mycallback (db, user_parameter, column, value)=
    _fooS strcat "user parameter : " user_parameter;
    _fooS strcat "column : " column;
    _fooS strcat "value : " value;
    0;;
    
    
    
fun opendb ()=

	
	let _checkpack "sqlite/test_1.db" -> existingdb in

	(
	if (existingdb == nil) then //there is no database, so create one, and open the one you have just created
	(
	//create an empty database
	_storepack "" "sqlite/test_1.db";
	let _sqliteOpenFile _channel _checkpack "sqlite/test_1.db" -> db in
	db;
	) 
	else
	(
	let _sqliteOpenFile _channel _checkpack "sqlite3/test_1.db" -> db in
	db;
	);
	);;
	
	fun main()=
	_showconsole;
	 let opendb -> db in
	 (
	 _sqliteCallbackExec db @mycallback "this is my callback" ;
	 _sqliteExec db "CREATE TABLE mytable (name char(50), surname char(50));";
	 let 0 -> counter in
	 //mess around and do some stuff with database!
	 while (counter < 100) do
	 (
	 _sqliteExec db "INSERT INTO mytable (name, surname) VALUES ('Thurman', 'Uma');";
	 set counter = counter +1;
	 );
	 _sqliteExec db "SELECT surname FROM mytable";
	 _fooS _sqliteVersion;

	);;
	 

Last edited by hebdemnobad (21-Oct-2024 01:12:52)

Offline

Board footer

Powered by FluxBB