Giter Club home page Giter Club logo

rebol-sqlite's Introduction

Rebol-SQLite CI Gitter

Rebol/SQLite

SQLite extension for Rebol3

Current state of the extension is under development and may be changed in any moment. For usage example see the test file.

rebol-sqlite's People

Contributors

oldes avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

rebol-sqlite's Issues

[WISH] simple form of evaluating statements with parameters

When populating a database, I can see code patterns like:

stmt: sqlite/prepare db {
	INSERT INTO Authors (first_name, family_name, date_of_birth, date_of_death)
	VALUES (?,?,?,?)
}
sqlite/step/with stmt ["Patrick" "Rothfuss" "1973-06-06" none]
sqlite/step/with stmt ["Ben" "Bova" "1932-11-8" none]
sqlite/step/with stmt ["Isaac" "Asimov" "1920-01-02" "1992-04-06"]
sqlite/step/with stmt ["Bob" "Billings" none none]
sqlite/step/with stmt ["Jim" "Jones" "1971-12-16" none]
sqlite/finalize stmt

It is using the low level step command, but it could be simplified using a new command, which could look like:

sqlite/eval db [
	{INSERT INTO Authors (first_name, family_name, date_of_birth, date_of_death) VALUES (?,?,?,?)}
	["Patrick" "Rothfuss" "1973-06-06"             ]
	["Ben"     "Bova"     "1932-11-08"             ]
	["Isaac"   "Asimov"   "1920-01-02" "1992-04-06"]
	["Bob"     "Billings"                          ]
	["Jim"     "Jones"    "1971-12-16"             ]
]

Using block for each record above. It may accept also flat data for multiple records like:

sqlite/eval db [
	"INSERT INTO Genres (name) VALUES (?)"
	"Fantasy" "Science Fiction" "French Poetry"
]

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.

INSERT prepared statement fails with accented chars

Hi Oldes
A few weeks ago (actually, I think it was 2 months ago), I wrote that I was going to test and use Rebol3-SQLite quite extensively and would post issues I encounters.
Voilà, here is the first one, very annoying for non english users :)

I have detected and tested this issue on Haiku Beta 4.

print "Trying to import SQLite extension..."
;; make sure that we load a fresh extension
try [system/modules/sqlite: none]
sqlite: import 'sqlite

recycle/torture

with sqlite [
	db: open %test.db

	;- The folowwing statement works fine
	exec db {
		BEGIN TRANSACTION;
		DROP TABLE IF EXISTS Contacts;
		CREATE TABLE Contacts (
			email TEXT PRIMARY KEY,
			first_name TEXT NOT NULL,
			last_name TEXT NOT NULL
		);
		INSERT INTO "Contacts" VALUES(
			'[email protected]',
			'Océane', 'Pacôme'
		);
		COMMIT;

	}
	;- The following statement does not work:
	;- the persisted value for first_name is "O" and 
	;- the persisted value for last_name is "P"
	stmt: prepare db "INSERT INTO Contacts VALUES(?,?,?);"
	rec: step/with stmt ["[email protected]" "Océane Jr" "Pacôme"]
	
	exec db "SELECT * FROM Contacts"
	close db
	shutdown
]

I hope you will be able to fix this soon.

Regards

François

Using `step` command on a prepared statement which has no more data should not return `true`

It can be demonstrated using:

sqlite: import 'sqlite
with sqlite [
	db: open %temp.db
	;; create a table with just one row
	exec db {
BEGIN TRANSACTION;
CREATE TABLE Cars(Id INTEGER PRIMARY KEY, Name TEXT, Price INTEGER);
INSERT INTO "Cars" VALUES(1,'Audi',52642);
COMMIT;}
	;; prepare the statement
	stmt: prepare db "SELECT * FROM Cars"
	;; get first row...
	probe step stmt ;== [1 "Audi" 52642]
	;; try to get row past end...
	probe step stmt ;== true; but it should be none
	close db
]
try [delete %temp.db]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.