azadkuh / sqlite-amalgamation

The SQLite amalgamation mirror with cmake
http://www.sqlite.org/amalgamation.html
BSD 3-Clause "New" or "Revised" License
92 stars 63 forks source link

sqlite-almagamation with embedded python3 #5

Open pipiche38 opened 4 years ago

pipiche38 commented 4 years ago

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 ?

azadkuh commented 4 years ago

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.

SylvainPer commented 4 years ago

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.