Closed Oldes closed 1 year ago
@fvanzeveren: can you help me to decide, if command like:
sqlite/eval db "SELECT * FROM Genres"
should be processed using the sqlite_exec
call, or using sqlite_prepare
+sqlite_step
+sqlite_finalize
?
The difference is, that sqlite_exec
can process multiple statements (like does current extension's exec
command)... the disadvantage of it is, that only column names and text representation of values can be collected using a callback.
I almost think, that I would use the version with step
.. like in case, when there are no parameters:
sqlite/eval db ["SELECT * FROM Genres"]
Because the multi-statement queries should not be used to collect any data anyway, because it is almost impossible to see, what SQL statement created the data:/
@Oldes I have read that sqlite_exec is a wrapper for
sqlite/begin
, sqlite/rollback
and sqlite/commit
.
Finally, sqlite/last-insert-rowid
could be interesting.CHeers
François
@Oldes Could you build a windows version with this fix? Indeed, I am able to complile for linux and Haiku, but I am struggling to set-up the build environment on Windows. Windows is a pain when it comes to develop :/
Thank you.
Note: why a 'sqlite scheme? Why not 'sql, so that when other backends databases (MySQL, MariaDB, Oracle, etc...) will be available ;), we could have the same 'scheme to avoid impacting scripts.
I have updated binaries available here with the current state: https://github.com/Siskin-framework/Rebol-SQLite/releases/tag/3.42.0.0
Btw... I use Github Actions to make releases: https://github.com/Siskin-framework/Builder/actions/runs/5270302675
It will be easy to add sqlite/last-insert-id
as there is a dedicated function for it. Meanwhile you can use: "SELECT last_insert_rowid();"
But there is no API for begin
, rolback
, commit
etc.. you must use queries for it.
Note: why a 'sqlite scheme? Why not 'sql, so that when other backends databases (MySQL, MariaDB, Oracle, etc...) will be available ;), we could have the same 'scheme to avoid impacting scripts.
As long as schemes will be compatible, it makes sense to have these separated.. you may have:
db: open sqlite:file.db
And or:
db: open mysql://localhost:9000
And then use in code scheme actions like insert db
, read db
etc... and don't care, if the db
is sqlite
or mysql
.
When populating a database, I can see code patterns like:
It is using the low level
step
command, but it could be simplified using a new command, which could look like:Using block for each record above. It may accept also flat data for multiple records like:
First value of the command's block could be string or prepared statement handle. In case of string the command would prepare and finalize the statement itself.