Why are sqlite3 shortcut functions called "nonstandard"?

Viewed 181

I've used sqlite3 in Python in which execute() creates ambiguity. When I use:

import sqlite3
A = sqlite3.connect('a')
A.execute('command to be executed')
help(A.execute)

I got the output of help() as:

.....
.....
Executes a SQL statement. Non-standard.

But when I execute like this:

import sqlite3
A = sqlite.connect('a').cursor()
A.execute('command to be executed')
help(A.execute)

I got the output of help() as:

.....
.....
Executes a SQL statement.

My doubt is what does Non-standard refer to? Even the Python documentation provides these words execute for execute(), executemany(), and executescript() in connection objects.

I've even searched in web about nonstandard shortcuts in Python. But I didn't get any relevant information. Can anyone help me with this?

1 Answers

The "nonstandard" function is the execute method of the sqlite3.Connection class:

This is a nonstandard shortcut that creates a cursor object by calling the cursor() method, calls the cursor’s execute() method with the parameters given, and returns the cursor.

"Standard" refers to PEP 249 -- Python Database API Specification v2.0 which the sqlite3 module follows. It does not specify an execute method for the Connection class, but the sqlite3 module provides it anyway, that's why it is called "nonstandard".

PEP 249 only specifies the execute method of the Cursor class, which the sqlite3 module implements, of course.

Related