@@ -837,11 +837,17 @@ def _query_iterator(
837
837
self , result , chunksize , columns , coerce_float = True , parse_dates = None
838
838
):
839
839
"""Return generator through chunked result set."""
840
+ has_read_data = False
840
841
while True :
841
842
data = result .fetchmany (chunksize )
842
843
if not data :
844
+ if not has_read_data :
845
+ yield DataFrame .from_records (
846
+ [], columns = columns , coerce_float = coerce_float
847
+ )
843
848
break
844
849
else :
850
+ has_read_data = True
845
851
self .frame = DataFrame .from_records (
846
852
data , columns = columns , coerce_float = coerce_float
847
853
)
@@ -1229,11 +1235,21 @@ def _query_iterator(
1229
1235
result , chunksize , columns , index_col = None , coerce_float = True , parse_dates = None
1230
1236
):
1231
1237
"""Return generator through chunked result set"""
1238
+ has_read_data = False
1232
1239
while True :
1233
1240
data = result .fetchmany (chunksize )
1234
1241
if not data :
1242
+ if not has_read_data :
1243
+ yield _wrap_result (
1244
+ [],
1245
+ columns ,
1246
+ index_col = index_col ,
1247
+ coerce_float = coerce_float ,
1248
+ parse_dates = parse_dates
1249
+ )
1235
1250
break
1236
1251
else :
1252
+ has_read_data = True
1237
1253
yield _wrap_result (
1238
1254
data ,
1239
1255
columns ,
@@ -1686,14 +1702,20 @@ def _query_iterator(
1686
1702
cursor , chunksize , columns , index_col = None , coerce_float = True , parse_dates = None
1687
1703
):
1688
1704
"""Return generator through chunked result set"""
1705
+ has_read_data = False
1689
1706
while True :
1690
1707
data = cursor .fetchmany (chunksize )
1691
1708
if type (data ) == tuple :
1692
1709
data = list (data )
1693
1710
if not data :
1694
1711
cursor .close ()
1712
+ if not has_read_data :
1713
+ yield DataFrame .from_records (
1714
+ [], columns = columns , coerce_float = coerce_float
1715
+ )
1695
1716
break
1696
1717
else :
1718
+ has_read_data = True
1697
1719
yield _wrap_result (
1698
1720
data ,
1699
1721
columns ,
0 commit comments