On this page
  1. sqlite3.Connection
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

sqlite3.Connection

Prev: sqlite3.connect | Up: sqlite3 | Next: sqlite3.Cursor
Rel: sqlite3.adapt, sqlite3.Binary, sqlite3.Blob, sqlite3.complete_statement
Ref: docs.python.org — sqlite3.Connection
Tags: #public #python3 #stdlib #sqlite3


Import

import sqlite3
from sqlite3 import Connection

Signature & Overview

sqlite3.Connection(...)

SQLite database connection object.

Methods & Attributes

Usage

import sqlite3

con = sqlite3.connect(":memory:")
try:
    with con:   # commits on success, rolls back on exception
        con.execute("CREATE TABLE items (name TEXT)")
        con.execute("INSERT INTO items VALUES (?)", ("widget",))
    assert con.execute("SELECT name FROM items").fetchone() == ("widget",)
finally:
    con.close()

Gotchas

REPL Inspect

from sqlite3 import Connection
help(Connection)

Linked from

Related notes