Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I import the sqlite3 module into Python 2.4?

Tags:

People also ask

What is the correct syntax to import sqlite3 module?

#!/usr/bin/python import sqlite3 conn = sqlite3. connect('test. db') print "Opened database successfully"; Here, you can also supply database name as the special name :memory: to create a database in RAM.

Do I need to pip install sqlite3?

You don't need to install sqlite3 module. It is included in the standard library (since Python 2.5).


The sqlite3 module is included in Python version 2.5+. However, I am stuck with version 2.4. I uploaded the sqlite3 module files, added the directory to sys.path, but I get the following error when I try to import it:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "sqlite3/__init__.py", line 23, in ?
    from dbapi2 import *
  File "sqlite3/dbapi2.py", line 26, in ?
    from _sqlite3 import *
ImportError: No module named _sqlite3

The file '_sqlite3' is in lib-dynload, but if I include this in the sqlite3 directory, I get additional errors.

Any suggestions? I am working in a limited environment; I don't have access to GCC, among other things.