Why cannot I import sqlite3?

As shown in the figure

Report it as a bug.

From the output and looking at directory in program files, this is what appears to happen:

  1. Imports sqlite3 module by calling dbapi2
  2. dbapi2 refers to _sqlite3 so the "_" underscore causes error
  3. Removing the "_" will still fail because dbapi2 is not importing everything nor using module name to call functions or constants, so the version constant will cause error
  4. The dbapi2 interface does not seem to work, so I tried modifying the __init__ file for the sqlite3 module to call the dbapi interface in the test/ directory. The import was successful, but useless because the expected functions were not imported nor recognized in Python Script
Not going to debug further.

Hey wangchengyang,

Seems like there is an issue with that library. Probably the libraries were not recompiled correctly.

Please send an email to support so this issue is corrected in a future version.

Mine can work normally, please refer to the attachment

sqlite_demo.vcmx (472 KB)

Add the folder path of sqlite3. DLL to the environment variable. For example, my path is as follows:D:\Program Files\Visual Components\Visual Components Premium 4.1\Python\DLLs

It has been tested many times and can run normally


This is most likely caused by the sys.path not being able to resolve paths containing Unicode characters.
If your VC installation location contains non-ASCII characters the python interpreter is unable to load the dependencies/imports. It’s a limitation in Python 2.7.

You can check the python system paths by e.g. writing to a component script and compile:
import sys
print sys.path

It will output a list of defined paths.

I have tested that if the DLL file is placed in the above path, there will still be problems after a period of time. Try again to test it in the following path. OK. For your reference.
path: D:\Program Files\Visual Components\Visual Components Premium 4.1
sqlite3.dll (753 KB)