Re: Jeremy, sqlite.e
- Posted by Jeremy Cowgar Jul 13, 2008
- 731 views
Saw in a previous post re ifdef that you use sqlite.e optionally.
Have you made any changes to the wrapper that could be added to the repository on wikispaces? Or this is a completely rewritten from scratch wrapper? If so, I would be interested to see it.
Chris, I borrowed heavily, but sqlite.e is not done on my side. Basically, I am writing a DBI that will allow users to choose which DB they want to use w/o changing their code (if they use a common SQL set, of course). Once I have more time, I will complete the sqlite.e version and then possibly use loadable dll files so that database engines could be changed on the fly w/o even an ifdef statement. Here's an example of the API thus far, but it's still in it's infancy and the API is bound to change very much before it's all done with...
ifdef PGSQL then include pgsql.e constant conn_str = "dbname=johndoe host=localhost" elsifdef SQLITE then include sqlite.e constant conn_str = "myfile.db" elsifdef MYSQL then include mysql.e constant conn_str = {"johndoe", 0, 0} end ifdef db:connection dbh = db:connect(conn_str) if dbh[ERROR] then puts(1, "Could not open database: %d, %s", {dbh[ERROR], dbh[ERROR_MESSAGE]}) abort(1) end if printf("%d people\n", {db:query_one(dbh, "SELECT COUNT(id) FROM people")}) db:result dbr = db:query(dbh, "SELECT id, name, state FROM people WHERE id > %d AND city=%s", {5, "Small'Town"}) while db:valid_row(dbr) do printf(1, "%5d: %s lives in %s\n", {db:get(dbr, 1), db:get(dbr, "name"), db:get(dbr, 3)}) if not db:execute(dbh, "UPDATE people SET viewed=%d, name=%s WHERE id=%d", {1, "Mc'Donald", db:get(dbr, "id")}) then -- handle error end if dbr = db:next(dbr) end while db:rclose(dbr) db:close(dbh)
So, it's a pretty simple API. Now, it does do a few things that are nice, such as when querying data, it converts the data types to the correct euphoria type (include datetime). With SQLite that appears to be a problem as I cannot get type information?
Anyway, the sqlite.e that I have is in no way a replacement for your sqlite. Your sqlite is a full wrapping which is very important for many applications who want to utilize sqlite to it's fullest and have no desire/need to use other database engines as well.
Jeremy