@@ -318,6 +318,7 @@ def print_(input_encoding, output_encoding, input_locale, output_locale,
318
318
@click .option ('--output-encoding' )
319
319
@click .option ('--input-locale' )
320
320
@click .option ('--output-locale' )
321
+ @click .option ('--samples' , default = 1000 )
321
322
@click .option ('--verify-ssl' , default = True , type = bool )
322
323
@click .option ('--output' )
323
324
@click .argument ('query' , required = True )
@@ -341,26 +342,31 @@ def query(input_encoding, output_encoding, input_locale, output_locale,
341
342
else :
342
343
if input_locale is not None :
343
344
with rows .locale_context (input_locale ):
344
- table = import_from_source (source , DEFAULT_INPUT_ENCODING )
345
+ table = import_from_source (source , DEFAULT_INPUT_ENCODING ,
346
+ lazy = True , samples = samples )
345
347
else :
346
- table = import_from_source (source , DEFAULT_INPUT_ENCODING )
348
+ table = import_from_source (source , DEFAULT_INPUT_ENCODING ,
349
+ lazy = True , samples = samples )
347
350
348
351
sqlite_connection = sqlite3 .Connection (':memory:' )
349
352
rows .export_to_sqlite (table ,
350
353
sqlite_connection ,
351
354
table_name = 'table1' )
352
- result = rows .import_from_sqlite (sqlite_connection , query = query )
355
+ result = rows .import_from_sqlite (sqlite_connection , query = query ,
356
+ lazy = True , samples = samples )
353
357
354
358
else :
355
359
# TODO: if all sources are SQLite we can also optimize the import
356
360
if input_locale is not None :
357
361
with rows .locale_context (input_locale ):
358
362
tables = [_import_table (source , encoding = input_encoding ,
359
- verify_ssl = verify_ssl )
363
+ verify_ssl = verify_ssl , lazy = True ,
364
+ samples = samples )
360
365
for source in sources ]
361
366
else :
362
367
tables = [_import_table (source , encoding = input_encoding ,
363
- verify_ssl = verify_ssl )
368
+ verify_ssl = verify_ssl , lazy = True ,
369
+ samples = samples )
364
370
for source in sources ]
365
371
366
372
sqlite_connection = sqlite3 .Connection (':memory:' )
@@ -369,7 +375,8 @@ def query(input_encoding, output_encoding, input_locale, output_locale,
369
375
sqlite_connection ,
370
376
table_name = 'table{}' .format (index ))
371
377
372
- result = rows .import_from_sqlite (sqlite_connection , query = query )
378
+ result = rows .import_from_sqlite (sqlite_connection , query = query ,
379
+ lazy = True , samples = samples )
373
380
374
381
# TODO: may use sys.stdout.encoding if output_file = '-'
375
382
output_encoding = output_encoding or sys .stdout .encoding or \
0 commit comments