Best way for python table?

Any thoughts on the best way to implement a table (i.e. a small relational database) in python without using external modules of external databases and when the sqlite3 module is damaged or missing .

user:~ $ python3
>>> import sqlite3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/bns/rma/local/python/lib/python3.1/sqlite3/__init__.py", line 24, in <module>
    from sqlite3.dbapi2 import *
  File "/bns/rma/local/python/lib/python3.1/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ImportError: No module named _sqlite3
>>> ^D
user:~ $ python2.7
Python 2.7 (r27:82500, Jul 28 2010, 11:39:31)
[GCC 3.4.3 (csl-sol210-3_4-branch+sol_rpath)] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dcottr/local/lib/python2.7/sqlite3/__init__.py", line 24, in <module>
    from dbapi2 import *
  File "/home/dcottr/local/lib/python2.7/sqlite3/dbapi2.py", line 27, in <module>
    from _sqlite3 import *
ImportError: No module named _sqlite3
>>>
+3
source share
3 answers

Basically you can think of tables as a list of lists / tuples. Then you can have a dict to represent the indices.

Will you make queries in a table or just “have” it? Why do you need this?

+4
source

Use sqlite3.

  • It comes with python, you do not need external databases or additional modules.
  • . , .
  • .
  • , JOIN s

. , , .

+13

Since version python version 2.5 supports Sqlite . It is very light and not external.

+2
source

Source: https://habr.com/ru/post/1774125/


All Articles