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