1010import datetime
1111
1212import pytest
13- from dqlitewire .constants import ValueType
1413
1514from dqlitedbapi import connect
1615from dqlitedbapi .aio .connection import AsyncConnection
16+ from dqlitewire .constants import ValueType
1717
1818
1919@pytest .mark .integration
@@ -29,7 +29,9 @@ def test_naive_datetime_stays_naive(self, cluster_address: str) -> None:
2929 dt = datetime .datetime (2024 , 1 , 15 , 10 , 30 , 45 ) # noqa: DTZ001 - naive is the point
3030 with connect (cluster_address , database = "test_dt_naive" ) as conn :
3131 cursor = conn .cursor ()
32- cursor .execute ("CREATE TABLE IF NOT EXISTS dt_naive (id INTEGER PRIMARY KEY, ts DATETIME)" )
32+ cursor .execute (
33+ "CREATE TABLE IF NOT EXISTS dt_naive (id INTEGER PRIMARY KEY, ts DATETIME)"
34+ )
3335 cursor .execute ("DELETE FROM dt_naive" )
3436 cursor .execute ("INSERT INTO dt_naive (ts) VALUES (?)" , [dt ])
3537 cursor .execute ("SELECT ts FROM dt_naive" )
@@ -45,7 +47,9 @@ def test_aware_datetime_preserves_offset(self, cluster_address: str) -> None:
4547 dt = datetime .datetime (2024 , 6 , 15 , 12 , 30 , 45 , tzinfo = tz )
4648 with connect (cluster_address , database = "test_dt_aware" ) as conn :
4749 cursor = conn .cursor ()
48- cursor .execute ("CREATE TABLE IF NOT EXISTS dt_aware (id INTEGER PRIMARY KEY, ts DATETIME)" )
50+ cursor .execute (
51+ "CREATE TABLE IF NOT EXISTS dt_aware (id INTEGER PRIMARY KEY, ts DATETIME)"
52+ )
4953 cursor .execute ("DELETE FROM dt_aware" )
5054 cursor .execute ("INSERT INTO dt_aware (ts) VALUES (?)" , [dt ])
5155 cursor .execute ("SELECT ts FROM dt_aware" )
@@ -72,7 +76,9 @@ def test_null_datetime_returns_none(self, cluster_address: str) -> None:
7276 """NULL in a DATETIME column is None on read (not an exception)."""
7377 with connect (cluster_address , database = "test_dt_null" ) as conn :
7478 cursor = conn .cursor ()
75- cursor .execute ("CREATE TABLE IF NOT EXISTS dt_null (id INTEGER PRIMARY KEY, ts DATETIME)" )
79+ cursor .execute (
80+ "CREATE TABLE IF NOT EXISTS dt_null (id INTEGER PRIMARY KEY, ts DATETIME)"
81+ )
7682 cursor .execute ("DELETE FROM dt_null" )
7783 cursor .execute ("INSERT INTO dt_null (ts) VALUES (NULL)" )
7884 cursor .execute ("SELECT ts FROM dt_null" )
@@ -117,7 +123,9 @@ def test_integer_value_in_datetime_column_decodes_as_datetime(
117123 epoch = int (expected .timestamp ())
118124 with connect (cluster_address , database = "test_unixtime" ) as conn :
119125 cursor = conn .cursor ()
120- cursor .execute ("CREATE TABLE IF NOT EXISTS ut_test (id INTEGER PRIMARY KEY, ts DATETIME)" )
126+ cursor .execute (
127+ "CREATE TABLE IF NOT EXISTS ut_test (id INTEGER PRIMARY KEY, ts DATETIME)"
128+ )
121129 cursor .execute ("DELETE FROM ut_test" )
122130 # Bind an int — SQLite stores it as INTEGER affinity; server then
123131 # tags the column as DQLITE_UNIXTIME on readback.
@@ -136,11 +144,11 @@ class TestDescriptionTypeCode:
136144 def test_iso8601_column_description (self , cluster_address : str ) -> None :
137145 with connect (cluster_address , database = "test_desc_iso" ) as conn :
138146 cursor = conn .cursor ()
139- cursor .execute ("CREATE TABLE IF NOT EXISTS desc_iso (id INTEGER PRIMARY KEY, ts DATETIME)" )
140- cursor .execute ("DELETE FROM desc_iso" )
141147 cursor .execute (
142- "INSERT INTO desc_iso (ts) VALUES (?)" , [ "2024-01-15 10:30:45" ]
148+ "CREATE TABLE IF NOT EXISTS desc_iso (id INTEGER PRIMARY KEY, ts DATETIME)"
143149 )
150+ cursor .execute ("DELETE FROM desc_iso" )
151+ cursor .execute ("INSERT INTO desc_iso (ts) VALUES (?)" , ["2024-01-15 10:30:45" ])
144152 cursor .execute ("SELECT id, ts FROM desc_iso" )
145153 cursor .fetchall ()
146154 assert cursor .description is not None
0 commit comments