1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
- case: raw_default_connection
main: |
from typing_extensions import reveal_type
from django.db import connection
with connection.cursor() as cursor:
reveal_type(cursor) # N: Revealed type is "django.db.backends.utils.CursorWrapper"
cursor.execute("SELECT %s", [123])
- case: raw_connection_psycopg2_composable
main: |
from django.db import connection
from psycopg2.sql import SQL, Identifier # type: ignore [import-untyped]
with connection.cursor() as cursor:
cursor.execute(SQL("INSERT INTO {} VALUES (%s)").format(Identifier("my_table")), [123])
- case: raw_connections
main: |
from typing_extensions import reveal_type
from django.db import connections
reveal_type(connections["test"]) # N: Revealed type is "django.db.backends.base.base.BaseDatabaseWrapper"
for connection in connections.all():
with connection.cursor() as cursor:
reveal_type(cursor) # N: Revealed type is "django.db.backends.utils.CursorWrapper"
|