not authorized
SQLITE_AUTH (result code 23) is returned when an authorizer callback (registered via sqlite3_set_authorizer()) denies permission for a specific SQL operation. SQLite itself has no built-in user/role permission system — this error only appears when the application explicitly installs an authorizer to restrict what SQL can be executed, a common pattern in embedded scripting and untrusted query environments.
- 1The application registered an authorizer callback that returns SQLITE_DENY for the attempted operation
- 2A security wrapper around SQLite is blocking DDL operations (CREATE, DROP) from untrusted input
- 3Read-only authorizer blocks an INSERT, UPDATE, or DELETE
An authorizer callback blocks all write operations.
import sqlite3
conn = sqlite3.connect(':memory:')
conn.execute('CREATE TABLE t (x INTEGER)')
def authorizer(action, arg1, arg2, db_name, trigger):
import sqlite3 as _sqlite3
if action == _sqlite3.SQLITE_INSERT:
return _sqlite3.SQLITE_DENY # block all inserts
return _sqlite3.SQLITE_OK
conn.set_authorizer(authorizer)
conn.execute('INSERT INTO t VALUES (1)') # triggers SQLITE_AUTHexpected output
sqlite3.DatabaseError: not authorized
Fix
Adjust the authorizer callback logic
WHEN When a legitimate operation is being incorrectly blocked.
def authorizer(action, arg1, arg2, db_name, trigger):
import sqlite3 as _sqlite3
# Allow reads, block writes from untrusted path
if action in (_sqlite3.SQLITE_INSERT, _sqlite3.SQLITE_UPDATE, _sqlite3.SQLITE_DELETE):
if db_name == 'untrusted':
return _sqlite3.SQLITE_DENY
return _sqlite3.SQLITE_OKWhy this works
The authorizer callback receives the action code and object names. Returning SQLITE_DENY blocks the operation; SQLITE_OK allows it; SQLITE_IGNORE suppresses the column access without error. Refine the logic to allow legitimate operations.
✕ Remove the authorizer entirely to fix the error
If the authorizer was installed deliberately (e.g., to sandbox untrusted SQL), removing it defeats the security layer.
SQLITE_AUTH is only raised if sqlite3_set_authorizer() has been called. Standard SQLite applications without an authorizer will never see this error.
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev