Page 1 of 1

SQLite3 open db problem

Posted: Wed Aug 05, 2026 1:22 am
by NubeCheCorre
Hi to everyone,
I am trying to learn the database plugin for hollywood as I want to use it for my small cms program. I have experience in mysql using lampp and php and javascript and so on..

As I said before I am learning hollywood as I would like to start using it not only for games creation but also for small cms program but I have problem to create a database using the function sqlite3.open(). I have no problem using the open_memory function but I would like to open a local or create a local db instead of using the ram..

This is the code I use:
@REQUIRE "sqlite3"
@APPTITLE "DB"
@APPVERSION "$VER: GUI 1.0 (23.06.2026)"
@APPCOPYRIGHT "Copyright ©2026, Davide Palombo"
@APPAUTHOR "Davide Palombo"
@APPDESCRIPTION "Esercizio db Hollywood"

/*local database = sqlite3:open_memory()*/

local myDB = sqlite3:open('./prova.db',SQLITE_OPEN_READWRITE)

myDB:exec([[

CREATE TABLE customer (
id INTEGER PRIMARY KEY AUTOINCREMENT,
nome TEXT NOT NULL,
cognome TEXT NOT NULL,
eta INT NOT NULL
);

]])

myDB:close()
and this is the error I receive from Hollywood:
Character constant too long (line 10)
Any hint is appreciated
Thanks

Re: SQLite3 open db problem

Posted: Wed Aug 05, 2026 3:49 am
by plouf
hello

1. stings in hollywood are included in double quotes "" , single quotes are for singlecharacode code
2. sql.open takes a single argumetns and dot , not :

btw if SQLITE_OPEN_READWRITE was a constant shall be with #, all cosntants in hollywood start with #

(is this AI "Help" genereated code ?:))

here

Code: Select all

@REQUIRE "sqlite3"
@APPTITLE "DB"
@APPVERSION "$VER: GUI 1.0 (23.06.2026)"
@APPCOPYRIGHT "Copyright ©2026, Davide Palombo"
@APPAUTHOR "Davide Palombo"
@APPDESCRIPTION "Esercizio db Hollywood"

/*local database = sqlite3:open_memory()*/

Local myDB = sqlite3.open("prova.db")

myDB:exec([[

CREATE TABLE customer (
id INTEGER PRIMARY KEY AUTOINCREMENT,
nome TEXT NOT NULL,
cognome TEXT NOT NULL,
eta INT NOT NULL
);

]])

myDB:close() 

Re: SQLite3 open db problem

Posted: Wed Aug 05, 2026 10:41 pm
by NubeCheCorre
I took the code from the examples included into sql plugin and from official page of sql lite lua as the included documentation for hollywood is unusable..

Re: SQLite3 open db problem

Posted: Wed Aug 05, 2026 10:53 pm
by NubeCheCorre
This code now works:
@REQUIRE "sqlite3"
@APPTITLE "DB"
@APPVERSION "$VER: GUI 1.0 (23.06.2026)"
@APPCOPYRIGHT "Copyright ©2026, Davide Palombo"
@APPAUTHOR "Davide Palombo"
@APPDESCRIPTION "Esercizio db Hollywood"

/*local database = sqlite3:open_memory()*/


local myDB = sqlite3.open("database")

myDB:exec([[

CREATE TABLE customer (
id INTEGER PRIMARY KEY AUTOINCREMENT,
nome TEXT NOT NULL,
cognome TEXT NOT NULL,
eta INT NOT NULL
);

]])

myDB:close()
From the official documentation of Lua and SQLite, sqlite3.open take name and arguments so i don't know what to say...

https://lua.sqlite.org/home/doc/tip/doc ... lite3_open

Re: SQLite3 open db problem

Posted: Thu Aug 06, 2026 6:21 am
by plouf
ok,

Hollywood has a slightly older version, teh exact documentation is included inside sqlite plguin you have download
on top of that, be aware that hollywood syntax , like use of double quotes for string, must apply since .this is hollywood :)

i.e i mean that all function in doc are implemented but documentation is not converted to hollywood,
even if syntax is almost the same some pecularities exist!

good luck to your projexct
except to see it :))

Re: SQLite3 open db problem

Posted: Thu Aug 06, 2026 3:16 pm
by NubeCheCorre
Thanks for all your help and kind words, really appreciated :)
May I ask you another thing please? Can you tell me if the sqlite3 engine db that we have here in Hollywood use the AUTOINCREMENT for the ID inside the table?
Thanks

EDIT: Yes, it has the AUTOINCREMENT parameter :-D

Re: SQLite3 open db problem

Posted: Thu Aug 06, 2026 6:26 pm
by plouf
yes your example does, it correct
here is a simple example

Code: Select all

@REQUIRE "sqlite3"
@APPTITLE "DB"
@APPVERSION "$VER: GUI 1.0 (23.06.2026)"
@APPCOPYRIGHT "Copyright ©2026, Davide Palombo"
@APPAUTHOR "Davide Palombo"
@APPDESCRIPTION "Esercizio db Hollywood"

;Local myDB = sqlite3:open_memory()
Local myDB = sqlite3.open("prova.db")

myDB:exec("CREATE TABLE customer (id INTEGER PRIMARY KEY AUTOINCREMENT,nome,cognome,eta );")

myDB:exec("INSERT INTO customer VALUES (NULL,'plouf','',0);")
myDB:exec("INSERT INTO customer VALUES (NULL,'Christos','',0);")

For row In myDB:nrows("SELECT * FROM customer")
	DebugPrint(row.id, row.nome)
Next


myDB:close()