MCPcopy Create free account
hub / github.com/dask/dask / read_sql_table

Function read_sql_table

dask/dataframe/io/sql.py:192–353  ·  view source on GitHub ↗

Read SQL database table into a DataFrame. If neither ``divisions`` or ``npartitions`` is given, the memory footprint of the first few rows will be determined, and partitions of size ~256MB will be used. Parameters ---------- table_name : str Name of SQL table i

(
    table_name,
    con,
    index_col,
    divisions=None,
    npartitions=None,
    limits=None,
    columns=None,
    bytes_per_chunk="256 MiB",
    head_rows=5,
    schema=None,
    meta=None,
    engine_kwargs=None,
    **kwargs,
)

Source from the content-addressed store, hash-verified

190
191
192def read_sql_table(
193 table_name,
194 con,
195 index_col,
196 divisions=None,
197 npartitions=None,
198 limits=None,
199 columns=None,
200 bytes_per_chunk="256 MiB",
201 head_rows=5,
202 schema=None,
203 meta=None,
204 engine_kwargs=None,
205 **kwargs,
206):
207 """
208 Read SQL database table into a DataFrame.
209
210 If neither ``divisions`` or ``npartitions`` is given, the memory footprint of the
211 first few rows will be determined, and partitions of size ~256MB will
212 be used.
213
214 Parameters
215 ----------
216 table_name : str
217 Name of SQL table in database.
218 con : str
219 Full sqlalchemy URI for the database connection
220 index_col : str
221 Column which becomes the index, and defines the partitioning. Should
222 be a indexed column in the SQL server, and any orderable type. If the
223 type is number or time, then partition boundaries can be inferred from
224 ``npartitions`` or ``bytes_per_chunk``; otherwise must supply explicit
225 ``divisions``.
226 columns : sequence of str or SqlAlchemy column or None
227 Which columns to select; if None, gets all. Note can be a mix of str and SqlAlchemy columns
228 schema : str or None
229 Pass this to sqlalchemy to select which DB schema to use within the
230 URI connection
231 divisions: sequence
232 Values of the index column to split the table by. If given, this will
233 override ``npartitions`` and ``bytes_per_chunk``. The divisions are the value
234 boundaries of the index column used to define the partitions. For
235 example, ``divisions=list('acegikmoqsuwz')`` could be used to partition
236 a string column lexographically into 12 partitions, with the implicit
237 assumption that each partition contains similar numbers of records.
238 npartitions : int
239 Number of partitions, if ``divisions`` is not given. Will split the values
240 of the index column linearly between ``limits``, if given, or the column
241 max/min. The index column must be numeric or time for this to work
242 limits: 2-tuple or None
243 Manually give upper and lower range of values for use with ``npartitions``;
244 if None, first fetches max/min from the DB. Upper limit, if
245 given, is inclusive.
246 bytes_per_chunk : str or int
247 If both ``divisions`` and ``npartitions`` is None, this is the target size of
248 each partition, in bytes
249 head_rows : int

Callers 15

test_emptyFunction · 0.90
test_single_columnFunction · 0.90
test_empty_other_schemaFunction · 0.90
test_needs_rationalFunction · 0.90
test_simpleFunction · 0.90
test_npartitionsFunction · 0.90
test_divisionsFunction · 0.90
test_metaFunction · 0.90
test_meta_no_head_rowsFunction · 0.90

Calls 2

read_sql_queryFunction · 0.85
popMethod · 0.80

Tested by 15

test_emptyFunction · 0.72
test_single_columnFunction · 0.72
test_empty_other_schemaFunction · 0.72
test_needs_rationalFunction · 0.72
test_simpleFunction · 0.72
test_npartitionsFunction · 0.72
test_divisionsFunction · 0.72
test_metaFunction · 0.72
test_meta_no_head_rowsFunction · 0.72