sqlite-amalgamation icon indicating copy to clipboard operation
sqlite-amalgamation copied to clipboard

sqlite-almagamation with embedded python3

Open pipiche38 opened this issue 5 years ago • 2 comments

This is more a question than an issue.

Python3 can be embedded in a C/C++ code and so forth can execute python3 code which use sqlite3.

In case we have a C/C++ code using SQLite3-almagamation and at the same time we have python3 calling SQLite via the shared library is the code safe ?

In other words don't we have a risk of conflict between the 2 same code ?

pipiche38 avatar Sep 24 '20 06:09 pipiche38

I'm sorry i have no experience in embedding python in c or c++, but I tried lua and c++ for a quick test, as lua uses the default *.so provided by OS, and the c++ uses this static sqlite-amalgamation with no problem.

This repo has a different include/lib path than system-wide sqlite, so your c/c++ will never get confused. I guess that you need to explicitly wrap these static functions into lua (or perhaps python) to use them there.

BTW you may want to trace/debug the sqlite functions to find out which version is being called.

azadkuh avatar Sep 26 '20 06:09 azadkuh

I try to trace what is happening with @pipiche38 issue.

I got this trace: dz_plantage_thread_plugin We can see that Plugins.cpp asks for python code execution, which leads to pysqlite and the libsqlite3.so before the embedded sqlite-almagamation. On my tests, it only appears after the database creation on a 'SELECT * FROM '. There is a segmentation fault because some parameters are not correctly initialized when running sqlite-almagamation, probably done in libsqlite3.so.

SylvainPer avatar Sep 30 '20 21:09 SylvainPer