@@ -1508,25 +1508,28 @@ def test_read_view_postgres(conn, request):
1508
1508
1509
1509
def test_read_view_sqlite (sqlite_buildin ):
1510
1510
# GH 52969
1511
- create_table = """
1512
- CREATE TABLE groups (
1511
+ table_uuid = table_uuid_gen ("groups" )
1512
+ view_uuid = table_uuid_gen ("group_view" )
1513
+
1514
+ create_table = f"""
1515
+ CREATE TABLE { table_uuid } (
1513
1516
group_id INTEGER,
1514
1517
name TEXT
1515
1518
);
1516
1519
"""
1517
- insert_into = """
1518
- INSERT INTO groups VALUES
1520
+ insert_into = f """
1521
+ INSERT INTO { table_uuid } VALUES
1519
1522
(1, 'name');
1520
1523
"""
1521
- create_view = """
1522
- CREATE VIEW group_view
1524
+ create_view = f """
1525
+ CREATE VIEW { view_uuid }
1523
1526
AS
1524
- SELECT * FROM groups ;
1527
+ SELECT * FROM { table_uuid } ;
1525
1528
"""
1526
1529
sqlite_buildin .execute (create_table )
1527
1530
sqlite_buildin .execute (insert_into )
1528
1531
sqlite_buildin .execute (create_view )
1529
- result = pd .read_sql ("SELECT * FROM group_view " , sqlite_buildin )
1532
+ result = pd .read_sql (f "SELECT * FROM { view_uuid } " , sqlite_buildin )
1530
1533
expected = DataFrame ({"group_id" : [1 ], "name" : "name" })
1531
1534
tm .assert_frame_equal (result , expected )
1532
1535
@@ -3947,9 +3950,10 @@ def sqlite_builtin_detect_types():
3947
3950
def test_roundtripping_datetimes_detect_types (sqlite_builtin_detect_types ):
3948
3951
# https://github.com/pandas-dev/pandas/issues/55554
3949
3952
conn = sqlite_builtin_detect_types
3953
+ table_uuid = table_uuid_gen ("test" )
3950
3954
df = DataFrame ({"t" : [datetime (2020 , 12 , 31 , 12 )]}, dtype = "datetime64[ns]" )
3951
- df .to_sql ("test" , conn , if_exists = "replace" , index = False )
3952
- result = pd .read_sql ("select * from test " , conn ).iloc [0 , 0 ]
3955
+ df .to_sql (table_uuid , conn , if_exists = "replace" , index = False )
3956
+ result = pd .read_sql (f "select * from { table_uuid } " , conn ).iloc [0 , 0 ]
3953
3957
assert result == Timestamp ("2020-12-31 12:00:00.000000" )
3954
3958
3955
3959
@@ -4238,8 +4242,10 @@ def test_xsqlite_basic(sqlite_buildin):
4238
4242
columns = Index (list ("ABCD" )),
4239
4243
index = date_range ("2000-01-01" , periods = 10 , freq = "B" ),
4240
4244
)
4241
- assert sql .to_sql (frame , name = "test_table" , con = sqlite_buildin , index = False ) == 10
4242
- result = sql .read_sql ("select * from test_table" , sqlite_buildin )
4245
+ table_uuid = table_uuid_gen ("test_table" )
4246
+ table_uuid2 = table_uuid_gen ("test_table2" )
4247
+ assert sql .to_sql (frame , name = table_uuid , con = sqlite_buildin , index = False ) == 10
4248
+ result = sql .read_sql (f"select * from { table_uuid } " , sqlite_buildin )
4243
4249
4244
4250
# HACK! Change this once indexes are handled properly.
4245
4251
result .index = frame .index
@@ -4251,8 +4257,8 @@ def test_xsqlite_basic(sqlite_buildin):
4251
4257
frame2 = frame .copy ()
4252
4258
new_idx = Index (np .arange (len (frame2 )), dtype = np .int64 ) + 10
4253
4259
frame2 ["Idx" ] = new_idx .copy ()
4254
- assert sql .to_sql (frame2 , name = "test_table2" , con = sqlite_buildin , index = False ) == 10
4255
- result = sql .read_sql ("select * from test_table2 " , sqlite_buildin , index_col = "Idx" )
4260
+ assert sql .to_sql (frame2 , name = table_uuid2 , con = sqlite_buildin , index = False ) == 10
4261
+ result = sql .read_sql (f "select * from { table_uuid2 } " , sqlite_buildin , index_col = "Idx" )
4256
4262
expected = frame .copy ()
4257
4263
expected .index = new_idx
4258
4264
expected .index .name = "Idx"
0 commit comments