Forum

Author Topic: SQLite in Python Api?  (Read 11108 times)

ju523m

  • Guest
SQLite in Python Api?
« on: December 19, 2011, 10:03:25 PM »
Hi All,

I would like to use the Python Api to build a Sqlite Database from within Photoscan using a Python-Script.
I have done some database programming with Python 2.6 / pysqlite2 / dbapi2 for other tasks so far.
There I usually use the following import statement:

from pysqlite2 import dbapi2

Does PS 0.8.4 1289 come with a complete SQlite Package? There is an Sqlite3-Sub-Folder in the PS Python3.2-Dir.

But when I use

from sqlite3.dbapi2 import *

I get an import Error: No module named _sqlite3

Any ideas welcome, thanks in advance.

kind regards

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: SQLite in Python Api?
« Reply #1 on: December 20, 2011, 05:23:59 PM »
Hello Thomas,

Unfortunately Python SQlite support library indeed is not packed in current version of PhotoScan Python. We plan to fix it in one of the next updates.

It may be possible to fix the problem manually by adding the support library to the PhotoScan Python folder.

Best regards,
Alexey Pasumansky,
Agisoft LLC

ju523m

  • Guest
Re: SQLite in Python Api?
« Reply #2 on: December 20, 2011, 05:35:04 PM »
Hi Alexey,
thanks for the very fast response and for opening up the Python scripting section.

Will try to get SQLItte3 running.

kind regards

ju523m

  • Guest
Re: SQLite in Python Api?
« Reply #3 on: December 22, 2011, 06:06:28 PM »
Hi Alexey,

yes, the library _sqlite3.so seems to be missing. In Python 2.6 it resides in folder lib-dynload.
To check if it is a Python issue, I  downloaded Python 3.2 and built it from source in a seperate folder of my homedir, following the description in the readme. file

It seems to be some kind of build-issue or configuration problem, because _sqlite3.so is also missing there. unfortunatel I did not manage to get it built properly.

kind regards

ju523m

  • Guest
SQlite in Python API? Solved!
« Reply #4 on: December 22, 2011, 10:36:51 PM »
Hi Alexey,

I think I have found a solution - googled some more around.

The sqlite library we need to get it running is only built and compiled when libsqlite3-dev development files are installed prior to building sqlite.

After rebuilding and recompilation of  sqlite3, there is a library "_sqlite3.cpython-32m.so" in the lib-dynload folder.

I then replaced the Photoscan Python3.2 folder with fresh built folder.

the import works now and I can connect to a database file:

from sqlite3 import dbapi2
dbapi2.connect('home/myhome/test.sdb')

Merry Christmas and a happy New Year

kind regards

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: SQLite in Python Api?
« Reply #5 on: December 23, 2011, 02:37:33 PM »
Hello Thomas,

Thank you for the detailed information. We'll fix it on our side too.
Best regards,
Alexey Pasumansky,
Agisoft LLC