mmottl / sqlite3-ocaml Goto Github PK
View Code? Open in Web Editor NEWOCaml bindings to the SQLite3 database
License: Other
OCaml bindings to the SQLite3 database
License: Other
SQLite-documentation says, there are the following functions, accessing values of certain types of columns:
sqlite3_column_blob()
sqlite3_column_bytes()
sqlite3_column_bytes16()
sqlite3_column_count()
sqlite3_column_double()
sqlite3_column_int()
sqlite3_column_int64()
sqlite3_column_text()
sqlite3_column_text16()
sqlite3_column_type()
sqlite3_column_value()
ocaml-sqlite has:
type t =
| NONE
| NULL
| INT of int64
| FLOAT of float
| TEXT of string
| BLOB of string
What is the used mapping?
And how is the mapping from SQL-statements mapped to Data-type?
For example if there is VARCHAR(), or any other SQL-type,
how to access it with ocaml-sqlite?
And: if reading a database is working by automatic coercion of the SQLite-types to ocaml-sqlite Data-type; what is done in case of the other direction? Mapping from a lower number of types to a higher number of types results in what?
Is that a safe operation?
Does it influence performance, if SQLIte adapts the types automatically?
For the db
and stmt
types there is a notice not to use them "WITHIN THREADS OTHER THAN THE ONE THAT CREATED IT". Comparing with the Sqlite3 documentation on thread safety:
SQLite supports three different threading modes:
Single-thread. In this mode, all mutexes are disabled and SQLite is unsafe to use in more than a single thread at once.
Multi-thread. In this mode, SQLite can be safely used by multiple threads provided that no single database connection is used simultaneously in two or more threads.
Serialized. In serialized mode, SQLite can be safely used by multiple threads with no restriction.
In the worst case scenario, sqlite3 is compiled for single-thread mode, in which case it would not be safe to use the library simultaneously from different threads even using different handles. This is probaby not very common, though. The default mode is serialized, and I would guess most distribution at least enables multi-thread.
If we assume at least multi-thread mode, then the requirement seems too strong. In particular, it should be safe to use a db
or stmt
from different threads, as long as access is locked by a per-db
and per-stmt
mutex. This is relevant to applications using Lwt_preemptiev
and Async.In_thread
. In Async.In_thread
there is a thread
argument which may help, but Lwt_preemptive
does not give control over which thread to use.
Can we assume the OCaml bindings does not bring in any additional threading issues? If so, maybe it would be better to refer to or relay the Sqlite3 documentation on the point?
Didn't used jbuilder so far.
jbuild-docs say, it needs no external components...
...well... but I got that err-msg:
jbuilder build @install --dev
Error: External library "base" not found.
-> required by "src/config/jbuild (context default)"
Hint: try: jbuilder external-lib-deps --missing --dev @install
make: *** [Makefile:4: all] Error 1
https://sqlite.org/carray.html looks to be the best way to parametrize queries/run statements with a variadic number of arguments. For example, a select x from y where z in (<a list of values here>)
. It seems like the API would be reasonably compact. What do you think?
Hello!
I'm hoping this is a rookie mistake… First, a note about my OPAM/OCaml setup itself: I made 4.13.1+muslnative+flambda
by installing the Musl GCC suite on my system, overriding $PATH
and $LD_LIBRARY_PATH
to use it, and then creating the switch. This built OCaml itself with Musl GCC and allows me to build 100% static executables with OCaml's -static
ccopt and no other special actions.
I want to start using SQLite3, so I downloaded the latest amalgamation and compiled it with SQLITE_OMIT_LOAD_EXTENSION
to avoid depending on -ldl
:
#!/bin/bash
MUSL="/usr/local/x86_64-linux-musl-native"
export PATH="${MUSL}/bin:${PATH}"
export LD_LIBRARY_PATH="${MUSL}/lib"
CFLAGS="-DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DQS=0 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_USE_ALLOCA" ./configure --disable-shared --prefix="${MUSL}"
gcc -Os -I. -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DQS=0 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_JSON1 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_USE_ALLOCA -c sqlite3.c
ar rcs libsqlite3.a sqlite3.o
sudo cp libsqlite3.a "${MUSL}/lib/"
sudo cp sqlite3.h "${MUSL}/include/"
sudo cp sqlite3.pc "${MUSL}/pkgconfig/"
I then tried:
MUSL="/usr/local/x86_64-linux-musl-native"
export PATH="${MUSL}/bin:${PATH}"
export LD_LIBRARY_PATH="${MUSL}/lib"
export SQLITE3_DISABLE_LOADABLE_EXTENSIONS=1
PKG_CONFIG_PATH="${MUSL}/pkgconfig" opam install sqlite3
…but somehow having the .pc
file there wasn't enough and it still wanted me to install my system's libsqlite3-dev
which wouldn't be appropriate. So I ran opam
again with --assume-depexts
which made conf-sqlite3
stand down and pretend it was installed.
Now my next hurdle is where I'm stuck: installing the sqlite3
package itself fails:
# ocamlmklib src/dllsqlite3_stubs.so,src/libsqlite3_stubs.a (exit 2)
# (cd _build/default && /home/lis/.opam/4.13.1+muslnative+flambda/bin/ocamlmklib.opt -g -o src/sqlite3_stubs src/sqlite3_stubs.o -L/usr/local/x86_64-linux-musl-native/lib -lsqlite3 -lpthread)
# /usr/local/x86_64-linux-musl-native/bin/../lib/gcc/x86_64-linux-musl/10.2.1/../../../../x86_64-linux-musl/bin/ld: /usr/local/x86_64-linux-musl-native/lib/libsqlite3.a(sqlite3.o): warning: relocation against `sqlite3_version' in read-only section `.text'
# /usr/local/x86_64-linux-musl-native/bin/../lib/gcc/x86_64-linux-musl/10.2.1/../../../../x86_64-linux-musl/bin/ld: /usr/local/x86_64-linux-musl-native/lib/libsqlite3.a(sqlite3.o): relocation R_X86_64_PC32 against symbol `sqlite3_version' can not be used when making a shared object; recompile with -fPIC
# /usr/local/x86_64-linux-musl-native/bin/../lib/gcc/x86_64-linux-musl/10.2.1/../../../../x86_64-linux-musl/bin/ld: final link failed: bad value
# collect2: error: ld returned 1 exit status
Typical non-static vs static stuff. The issue isn't so much -fPIC
but that the linking is dynamic, if memory serves. How could I tell opam that I'm not interested in dynamic building with this package?
Do I need to go as far making myself a local fork of this repo and renaming it sqlite3-static
just for this? Or do I actually need the .so
as well for things like utop
to work?
Note that this is my first attempt at using any non-OCaml dependency in this Musl GCC setup, so I apologize if this ends up being a generalized problem with static building with OCaml.
Also, this is for eventual commercial use (I convinced my client company that OCaml was the way to go, but that is predicated on having SQLite3 and other bindings running smoothly, probably under Lwt cooperative threading too…) Therefore I'm open to buying a couple hours of your time to iron this out if it's non-trivial. 😉
looking at https://sqlite.org/wal.html :
exec
does the job)because of guard on empty pkg-config output in 967198e
Seems to be an EOF error...
Any help would be much appreciated!
opam ins sqlite3
The following actions will be performed:
∗ install sqlite3 4.3.2
=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[sqlite3] Archive in cache
=-=- Processing actions -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[ERROR] The compilation of sqlite3 failed at "jbuilder build -p sqlite3 -j 4".
=== ERROR while installing sqlite3.4.3.2 =====================================#
opam-version 1.2.2
os linux
command jbuilder build -p sqlite3 -j 4
path /home/eliot/.opam/4.06.1/build/sqlite3.4.3.2
compiler 4.06.1
exit-code 1
env-file /home/eliot/.opam/4.06.1/build/sqlite3.4.3.2/sqlite3-20071-58c514.env
stdout-file /home/eliot/.opam/4.06.1/build/sqlite3.4.3.2/sqlite3-20071-58c514.out
stderr-file /home/eliot/.opam/4.06.1/build/sqlite3.4.3.2/sqlite3-20071-58c514.err
stderr ###
-> stdout:
[...]
| ast_impl_magic_number: Caml1999M022
| ast_intf_magic_number: Caml1999N022
| cmxs_magic_number: Caml1999D022
| cmt_magic_number: Caml1999T022
-> stderr:
Fatal error: exception End_of_file
Raised at file "src/import0.ml" (inlined), line 351, characters 22-32
Called from file "src/configurator.ml", line 511, characters 13-22
Called from file "src/config/discover.ml", line 42, characters 2-1023
=-=- Error report -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
The following actions failed
∗ install sqlite3 4.3.2
No changes have been performed
=-=- sqlite3.4.3.2 troobleshooting =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
=> This package relies on external (system) dependencies that may be missing. `opam depext sqlite3.4.3.2' may help you find the
correct installation for your system.
...
opam depext sqlite3.4.3.2
Detecting depexts using flags: x86_64 linux linuxmint
No extra OS packages requirements found.
I have a custom build of sqlite3, built for and installed into in a directory /PREFIX, and made this available via:
export PKG_CONFIG_PATH=/PREFIX/lib/pkgconfig
When now I try opam install sqlite3
, the build fails on dependency package conf-sqlite3
with empty logfiles.
The output of pkg-config
for the custom build is correct:
$ pkg-config --libs sqlite3
-L/PREFIX/lib -lsqlite3
$ pkg-config --cflags sqlite3
-I/PREFIX/include
Some final observations:
PKG_CONFIG_PATH
or PKG_CONFIG_LIBDIR
libsqlite3-dev
package (Debian) and use clean PKG_CONFIG_*
environment variables, everything worksDocumentation link leads to https://mmottl.github.io/sqlite3-ocaml/api/sqlite3 which 404s
Jbuilder has been renamed to Dune
https://github.com/ocaml/dune
Fatal error: exception Failure("This function always errors")
W: Test 'test_error' fails: Command '/home/ygrek/work/contrib/sqlite3-ocaml/_build/test/test_error.native' terminated with error code 2
E: Failure("Tests had a 16.67% failure rate")
Makefile:13: recipe for target 'test' failed
make: *** [test] Error 1
This started to happen with v4.0.0.
Here is the output from v3.0.0 which works ok :
This function always errors
Bind threw an error
Hi,
I'm wondering which license sqlite3-ocaml is under, since in the COPYING file it gives an expat-style license, while the opam
file says "LGPL-2.1+ with OCaml linking exception".
Thanks, ben.
I would like to add the extended error codes to the API. It seems straight forward except for how to define the error type, where I could use a second opinion. The options I consider are:
With option 1 we can't match whole categories directly. It will be possibly to match first on the normal error code, then on the detailed code where needed. The latter would not provide exhaustiveness checks within the category, which I think is its main limitation.
Option 2 would solve that, at the expense of having constructors with arguments (and breaking slightly with the style of the current API).
Option 3 would also solve it, at the expense of breaking with the style of the current API.
[Sorry for the initially empty issue, I hit enter by accident.]
Hi there,
Here's what I have.
protz@manaslu:/usr/x86_64-w64-mingw32/sys-root/mingw/bin $ strings libsqlite3-0.dll | grep OMIT_LOAD_EXTENSION
OMIT_LOAD_EXTENSION
so it seems to indicate that the library does not have loadable extensions. Yet, building the library does not fail.
This is on Windows, with protz.github.io/ocaml-installer/ followed by "opam install depext depext-cygwinports", then "opam depext sqlite3", then "opam install sqlite3".
protz@manaslu:/tmp/sqlite3.4.0.2 $ make
ocaml setup.ml -build
(snip)
''C:/cygwin/home/protz/.opam/system/bin/ocamlfind.EXE ocamlopt -a -cclib -lsqlite3_stubs -cclib -lsqlite3 -cclib -lpthread -cclib -lsqlite3 -cclib -lsqlite3 lib/sqlite3.cmx -o lib/sqlite3.cmxa
''C:/cygwin/home/protz/.opam/system/bin/ocamlfind.EXE ocamlopt -shared -cclib -lsqlite3_stubs -I lib -cclib -lsqlite3 lib/sqlite3.cmxa lib/sqlite3.cmx -o lib/sqlite3.cmxs
protz@manaslu:/tmp/sqlite3.4.0.2 $ echo $?
0
Of course, things fail later on. Here's the last line of my ocamlopt -verbose
invocation.
+ flexlink -chain mingw64 -stack 33554432 -exe -o "test.out" "-L../../../FStar/lib/ml/native_int" "-L../../../FStar/lib/ml/hyperheap" "-L../../../FStar/lib/ml" "-L../../../FStar/contrib/Platform/ml" "-L../../../FStar/contrib/CoreCrypto/ml" "-L../../../FStar/contrib/CoreCrypto/ml/db" "-L/home/protz/dev/mitls/mitls-fstar/src/tls" "-LC:/cygwin/home/protz/.opam/system/lib/num" "-LC:/cygwin/home/protz/.opam/system/lib/bytes" "-LC:/cygwin/home/protz/.opam/system/lib/batteries" "-LC:/cygwin/home/protz/.opam/system/lib/stdint" "-LC:/cygwin/home/protz/.opam/system/lib/fileutils" "-LC:/cygwin/home/protz/.opam/system/lib/sqlite3" "-LC:\OCaml\lib\threads" "-LC:\OCaml\lib" "C:\cygwin64\tmp\camlstartupf692dc.o" "C:\OCaml\lib\std_exit.o" "parsing_test.o" "HandshakeMessages.o" "TLSExtensions.o" "TLSInfo.o" "Cert.o" "UntrustedCert.o" "Sig.o" "HASH.o" "PMS.o" "CommonDH.o" "DHGroup.o" "ECGroup.o" "RSAKey.o" "Nonce.o" "../../../FStar/contrib/CoreCrypto/ml/DHDB.o" "TLSConstants.o" "TLSError.o" "FStar_SeqProperties.o" "FStar_Seq.o" "FStar_List_Tot.o" "../../../FStar/lib/ml/FStar_All.o" "../../../FStar/lib/ml/hyperheap/FStar_HyperHeap.o" "../../../FStar/lib/ml/hyperheap/FStar_ST.o" "../../../FStar/contrib/CoreCrypto/ml/corecrypto.a" "../../../FStar/contrib/CoreCrypto/ml/db/DB.o" "../../../FStar/lib/ml/native_int/prims.o" "../../../FStar/lib/ml/FStar_List.o" "C:/cygwin/home/protz/.opam/system/lib/sqlite3\sqlite3.a" "C:/cygwin/home/protz/.opam/system/lib/fileutils\fileutils.a" "C:/cygwin/home/protz/.opam/system/lib/stdint\stdint.a" "C:/cygwin/home/protz/.opam/system/lib/batteries\batteriesThread.a" "C:/cygwin/home/protz/.opam/system/lib/batteries\batteries.a" "C:/OCaml/lib\str.a" "C:/OCaml/lib\bigarray.a" "C:/OCaml/lib\nums.a" "C:/OCaml/lib/threads\threads.a" "C:/OCaml/lib\unix.a" "C:\OCaml\lib\stdlib.a" "-lcorecrypto" "-lcrypto" "-lsqlite3_stubs" "-lsqlite3" "-lpthread" "-lsqlite3" "-lsqlite3" "-lstdint_stubs" "-lcamlstr" "-lbigarray" "-lnums" "-lthreadsnat" "-lunix" "-lws2_32" "C:\OCaml\lib\libasmrun.a" -lws2_32
** Cannot resolve symbols for C:/cygwin/home/protz/.opam/system/lib/sqlite3\libsqlite3_stubs.a(sqlite3_stubs.o):
sqlite3_enable_load_extension
File "caml_startup", line 1:
Error: Error during linking
ocamlopt.opt.exe returned with exit code 2
Is this expected?
Can you provide a way to control this, say, with an environment variable? For instance, "SQLITE3_REALLY_DOESNT_HAVE_EXTENSIONS". Or, better, compile a sample program to actually determine whether extensions have been enabled or not.
Thanks,
Jonathan
trying to use Aggregate.create_fun1
but I consistently get a segfault in the finalize part. Accumulator type is string list option
. A trace follows:
Program terminated with signal SIGSEGV, Segmentation fault.
#0 camlBenchpress__Test__finalize_1603 () at src/core/Test.ml:251
251 | Nopath _ -> Db.Data.NULL
[Current thread is 1 (Thread 0x7f95d07fd640 (LWP 2552230))]
(gdb) bt
#0 camlBenchpress__Test__finalize_1603 () at src/core/Test.ml:251
#1 0x000056342437eb60 in caml_start_program ()
#2 0x0000563424353d6b in caml_sqlite3_user_function_final (ctx=0x7f95d07faed0) at sqlite3_stubs.c:1489
#3 0x00007f95d2f8328a in sqlite3VdbeMemFinalize () from /usr/lib/libsqlite3.so.0
#4 0x00007f95d2f74da4 in sqlite3VdbeExec () from /usr/lib/libsqlite3.so.0
#5 0x00007f95d2f7c0b8 in sqlite3_step () from /usr/lib/libsqlite3.so.0
#6 0x0000563424355d7d in caml_sqlite3_step (v_stmt=<optimized out>) at sqlite3_stubs.c:1174
#7 0x000056342423d917 in camlSqlite3_utils__next__423 () at src/sqlite3_utils.ml:171
#8 0x000056342423da3b in camlSqlite3_utils__make__427 () at src/sqlite3_utils.ml:181
#9 0x000056342423e9b3 in camlSqlite3_utils__fun_1351 () at src/sqlite3_utils.ml:323
#10 0x000056342423e0d6 in camlSqlite3_utils__finally__562 () at src/sqlite3_utils.ml:249
#11 0x0000563424226e1b in camlBenchpress__Test__fun_3901 () at src/core/Test.ml:418
#12 0x000056342421c34e in camlBenchpress__Misc__err_with_inner_3839 () at src/core/Misc.ml:203
#13 0x000056342422965b in camlBenchpress__Test__fun_4166 () at src/core/Test.ml:730
#14 0x000056342421c34e in camlBenchpress__Misc__err_with_inner_3839 () at src/core/Misc.ml:203
#15 0x000056342423e0d6 in camlSqlite3_utils__finally__562 () at src/sqlite3_utils.ml:249
#16 0x00005634241db285 in camlBenchpress_server__get_meta_4678 () at src/server/benchpress_server.ml:999
#17 0x00005634241dd102 in camlBenchpress_server__fun_11570 () at src/server/benchpress_server.ml:1110
#18 0x00005634241ce5d8 in camlBenchpress_server__f$27_3089 () at src/server/benchpress_server.ml:218
#19 0x000056342421c34e in camlBenchpress__Misc__err_with_inner_3839 () at src/core/Misc.ml:203
#20 0x00005634241ce4c5 in camlBenchpress_server__query_wrap_2895 () at src/server/benchpress_server.ml:223
#21 0x0000563424217b94 in camlTiny_httpd__handle_client__1334 () at src/Tiny_httpd.ml:913
#22 0x00005634242182ab in camlTiny_httpd__fun_2892 () at src/Tiny_httpd.ml:964
#23 0x000056342429f299 in camlThread__fun_286 () at thread.ml:39
#24 0x000056342437eb60 in caml_start_program ()
#25 0x00005634243575a0 in caml_thread_start ()
#26 0x00007f95d2e8a299 in start_thread () from /usr/lib/libpthread.so.0
#27 0x00007f95d2c67053 in clone () from /usr/lib/libc.so.6
I'm using the OCaml for windows repository, and the installation fails as pkg-config
is not recognized as a command.
Replacing all references from pkg-config
to pkgconf
in discover.ml
solve the problem, but I am not able to propose a clean PR for this.
While trying to install this package via OPAM, I got the following error:
#=== ERROR while installing sqlite3.2.0.7 =====================================#
# opam-version 1.2.0
# os linux
# command ocaml setup.ml -build
# path /home/frenetic/.opam/4.01.0/build/sqlite3.2.0.7
# compiler 4.01.0
# exit-code 1
# env-file /home/frenetic/.opam/4.01.0/build/sqlite3.2.0.7/sqlite3-2135-5f1023.env
# stdout-file /home/frenetic/.opam/4.01.0/build/sqlite3.2.0.7/sqlite3-2135-5f1023.out
# stderr-file /home/frenetic/.opam/4.01.0/build/sqlite3.2.0.7/sqlite3-2135-5f1023.err
### stdout ###
# ...[truncated]
# Turn ocaml profile flag on: .......................... false
# Compiler support generation of .cmxs.: ............... true
# OCamlbuild additional flags: .........................
# Strict compile-time checks: .......................... true
# Create documentations: ............................... true
# Compile tests executable and library and run them: ... false
# ocamldoc: ............................................ /home/frenetic/.opam/4.01.0/bin/ocamldoc
#
# /home/frenetic/.opam/4.01.0/bin/ocamlopt.opt unix.cmxa -I /home/frenetic/.opam/4.01.0/lib/ocaml/ocamlbuild /home/frenetic/.opam/4.01.0/lib/ocaml/ocamlbuild/ocamlbuildlib.cmxa myocamlbuild.ml /home/frenetic/.opam/4.01.0/lib/ocaml/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
# Failure: pkg-config failed for cflags.
### stderr ###
# Package sqlite3 was not found in the pkg-config search path.
# Perhaps you should add the directory containing `sqlite3.pc'
# to the PKG_CONFIG_PATH environment variable
# No package 'sqlite3' found
# E: Failure("Command ''/home/frenetic/.opam/4.01.0/bin/ocamlbuild' lib/libsqlite3_stubs.a lib/dllsqlite3_stubs.so lib/sqlite3.cma lib/sqlite3.cmxa lib/sqlite3.a lib/sqlite3.cmxs -tag debug' terminated with error code 2")
I tried building from source, and then got the following type error in myocamlbuild.ml
:
$ make
ocaml setup.ml -build
+ /usr/local/bin/ocamlopt.opt unix.cmxa -I /usr/local/lib/ocaml/ocamlbuild /usr/local/lib/ocaml/ocamlbuild/ocamlbuildlib.cmxa myocamlbuild.ml /usr/local/lib/ocaml/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
File "myocamlbuild.ml", line 753, characters 41-56:
Error: This expression has type MyOCamlbuildBase.t
but an expression was expected of type MyOCamlbuildFindlib.conf
Command exited with code 2.
Compilation unsuccessful after building 1 target (0 cached) in 00:00:00.
E: Failure("Command ''/usr/local/bin/ocamlbuild' lib/libsqlite3_stubs.a lib/dllsqlite3_stubs.so lib/sqlite3.cma lib/sqlite3.cmxa lib/sqlite3.a lib/sqlite3.cmxs -tag debug' terminated with error code 10")
*** Error code 1
Stop.
make: stopped in /tmp/sqlite3-ocaml
Upgrading my ocaml distribution using opam on macos led to the following error
#=== ERROR while installing sqlite3.4.0.3 =====================================#
# opam-version 1.2.2
# os darwin
# command ocaml setup.ml -build
# path /Users/william/.opam/system/build/sqlite3.4.0.3
# compiler system (4.02.3)
# exit-code 1
# env-file /Users/william/.opam/system/build/sqlite3.4.0.3/sqlite3-28580-d2c37b.env
# stdout-file /Users/william/.opam/system/build/sqlite3.4.0.3/sqlite3-28580-d2c37b.out
# stderr-file /Users/william/.opam/system/build/sqlite3.4.0.3/sqlite3-28580-d2c37b.err
### stdout ###
# /usr/local/bin/ocamlopt.opt unix.cmxa -I /usr/local/lib/ocaml/ocamlbuild /usr/local/lib/ocaml/ocamlbuild/ocamlbuildlib.cmxa myocamlbuild.ml /usr/local/lib/ocaml/ocamlbuild/ocamlbuild.cmx -o myocamlbuild
# /Users/william/.opam/system/bin/ocamlfind ocamlc -g -ccopt -g -ccopt -O2 -ccopt -fPIC -ccopt -DPIC -ccopt -Wall -ccopt -pedantic -ccopt -Wextra -ccopt -Wunused -ccopt -Wno-long-long -ccopt -Wno-keyword-macro -ccopt -I/usr/local/Cellar/sqlite/3.8.7.4/include -c lib/sqlite3_stubs.c
# + /Users/william/.opam/system/bin/ocamlfind ocamlc -g -ccopt -g -ccopt -O2 -ccopt -fPIC -ccopt -DPIC -ccopt -Wall -ccopt -pedantic -ccopt -Wextra -ccopt -Wunused -ccopt -Wno-long-long -ccopt -Wno-keyword-macro -ccopt -I/usr/local/Cellar/sqlite/3.8.7.4/include -c lib/sqlite3_stubs.c
# cc1: error: unrecognized command line option "-Wno-keyword-macro"
# Command exited with code 2.
### stderr ###
# E: Failure("Command ''/usr/local/bin/ocamlbuild' lib/libsqlite3_stubs.a lib/dllsqlite3_stubs.so lib/sqlite3.cma lib/sqlite3.cmxa lib/sqlite3.a lib/sqlite3.cmxs -tag debug' terminated with error code 10")
removing the -Wno-keyword-macro from the _oasis seems to do the trick
Even though I installed the package with opam, it is not available.
ocamlfind does not find it.
# Packages matching: match(*sqlite3*)
# Name # Installed # Synopsis
caqti-driver-sqlite3 -- Sqlite3 driver for Caqti using C bindings
conf-sqlite3 1 Virtual package relying on an SQLite3 system installation
ezsqlite -- Simplified SQLite3 bindings for OCaml
gensqlite -- A ppx preprocessor to generate SQLite3 prepared statements and query functions.
links-sqlite3 -- SQLite database driver for the Links Programming Language
pa_sqlexpr -- Type-safe, convenient SQLite database access - extension for use with sqlexpr.
ppx_sqlexpr -- Type-safe, convenient SQLite database access - extension for use with sqlexpr.
skkserv-lite -- SKK server using sqlite3 dictionaries
sqlexpr -- Type-safe, convenient SQLite database access.
sqlite3 5.0.3 SQLite3 bindings for OCaml
sqlite3_utils 0.3.1 High-level wrapper around ocaml-sqlite3
sqlite3EZ -- Thin wrapper for sqlite3-ocaml with a simplified interface
Used then ocamlfind:
ocamlfind query sqlite3
and got this:
ocamlfind: Package `sqlite3' not found
Hi Markus, I'm having issues with extensions:
This fails:
let () = assert (Sqlite3.enable_load_extension db true)
This returns an Error
:
let _ = Sqlite3.exec db "SELECT load_extension(\"sqlstat.so\")"
I have never had any issue with loading extensions in the sqlite3
interpreter (i.e. the SELECT load_extension(...)
statement above works fine).
I went back to the build dir in .opam
, ran the configure script again, and got
Enable loadable extensions: .......................... true
Also,
strings /usr/lib/i386-linux-gnu/libsqlite3.so.0 | grep OMIT
gives only OMIT_LOOKASIDE
.
Any ideas? Thanks!
Looking into the commit history I see Improved exception function declarations for MSVC commit, whose name suggests that sqlite3-ocaml can be built for Windows. Unfortunately that's not the case; 0329139 destroyed Windows compatibility opportunity introducing pthread API use that cannot be easily emulated under Windows (destructor function passed to pthread_key_create). I could try to put Windows compatibility back, but I would like to know first why user exceptions should be registered on per-thread basis?
Hi,
after updating from sqlite3 4.1.3
I get a linking error when building a project, which uses sqlite3 (same error for 4.2.0
& 4.3.0)
:
** Cannot resolve symbols for C:/Opt/OCaml64/home/kayuwekirstein/.opam/4.04.2+mingw64/lib\sqlite3\libsqlite3_stubs.a(sqlite3_stubs.o):
pthread_getspecific
pthread_key_create
pthread_setspecific
File "caml_startup", line 1:
Error: Error during linking
I can fix the linking by providing an additional -lpthread
switch to the jbuild config of my library, which seems to work on Windows (cygwin with MinGW toolchain), but still fails on WSL/BashForWindows (which is basically an Ubuntu 16.04).
After googling, I found out that this might be an issue with the order of the link flags on the command line, but I have no clue, on how to control that with jbuilder.
Anyway, does anybody have an idea, why it worked fine with 4.1.3 and is different with later versions (I wouldn't call it broken)? Maybe one can give an advice, on how to setup a project depending on sqlite3 (ideally with using jbuilder). I couldn't find a suitable one by reverse search of opam deps.
Is it possible to link an OCaml program statically to libsqlite3, i.e. that it links against libsqlite3.a
instead of libsqlite3.so.0
?
If so, is it also possible to do that with an OPAM-based installation of sqlite3-ocaml?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.