'from sqlite3 import dbapi2 as sqlite3' vs 'import sqlite3'?

When I see examples for pysqlite, there are two use cases for the SQLite library.

from sqlite3 import dbapi2 as sqlite3

and

import sqlite3

Why are there two ways to support sqlite3 api? What is the difference between the two? They are the same? Under normal use, which would be preferable.

ADDED

I knew that they are different in terms of the namespace, and I wanted to ask if they are the same in terms of usage , I mean that they have the same set of APIs?

+3
source share
2 answers

They are the same. In Lib/my Python installation directory (v2.6), the package sqlite3contains a file __init__.pywith this:

from dbapi2 import *

, .

, import sqlite3, .

+6

.

dbapi2 sqlite3 .

sqlite3 .

, dbapi2 (aliased as sqlite3), sqlite3.dbapi2 , .

. python

+1

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


All Articles