MCPcopy
hub / github.com/pandas-dev/pandas / read

Method read

pandas/io/sql.py:1167–1212  ·  view source on GitHub ↗
(
        self,
        exit_stack: ExitStack,
        coerce_float: bool = True,
        parse_dates=None,
        columns=None,
        chunksize: int | None = None,
        dtype_backend: DtypeBackend | Literal["numpy"] = "numpy",
    )

Source from the content-addressed store, hash-verified

1165 yield self.frame
1166
1167 def read(
1168 self,
1169 exit_stack: ExitStack,
1170 coerce_float: bool = True,
1171 parse_dates=None,
1172 columns=None,
1173 chunksize: int | None = None,
1174 dtype_backend: DtypeBackend | Literal["numpy"] = "numpy",
1175 ) -> DataFrame | Iterator[DataFrame]:
1176 from sqlalchemy import select
1177
1178 if columns is not None and len(columns) > 0:
1179 cols = [self.table.c[n] for n in columns]
1180 if self.index is not None:
1181 for idx in self.index[::-1]:
1182 cols.insert(0, self.table.c[idx])
1183 sql_select = select(*cols)
1184 else:
1185 sql_select = select(self.table)
1186 result = self.pd_sql.execute(sql_select)
1187 column_names = result.keys()
1188
1189 if chunksize is not None:
1190 return self._query_iterator(
1191 result,
1192 exit_stack,
1193 chunksize,
1194 column_names,
1195 coerce_float=coerce_float,
1196 parse_dates=parse_dates,
1197 dtype_backend=dtype_backend,
1198 )
1199 else:
1200 data = result.fetchall()
1201 self.frame = _convert_arrays_to_dataframe(
1202 data, column_names, coerce_float, dtype_backend
1203 )
1204
1205 self._harmonize_columns(
1206 parse_dates=parse_dates, dtype_backend=dtype_backend
1207 )
1208
1209 if self.index is not None:
1210 self.frame.set_index(self.index, inplace=True)
1211
1212 return self.frame
1213
1214 def _index_name(self, index, index_label):
1215 # for writing: index=True to include index in sql table

Callers 15

read_tableMethod · 0.95
process_tempitaFunction · 0.45
render_templatesMethod · 0.45
mainFunction · 0.45
mainFunction · 0.45
generate_pip_from_condaFunction · 0.45
mainFunction · 0.45
mainFunction · 0.45

Calls 7

_query_iteratorMethod · 0.95
_harmonize_columnsMethod · 0.95
set_indexMethod · 0.80
insertMethod · 0.45
executeMethod · 0.45
keysMethod · 0.45

Tested by 2

mainFunction · 0.36