def csv_to_sqlite(<EOL>input_filename,<EOL>output_filename,<EOL>samples=None,<EOL>dialect=None,<EOL>batch_size=<NUM_LIT>,<EOL>encoding="<STR_LIT:utf-8>",<EOL>callback=None,<EOL>force_types=None,<EOL>chunk_size=<NUM_LIT>,<EOL>table_name="<STR_LIT>",<EOL>schema=None,<EOL>):
<EOL>if dialect is None:  <EOL><INDENT>fobj = open_compressed(input_filename, mode="<STR_LIT:rb>")<EOL>sample = fobj.read(chunk_size)<EOL>dialect = rows.plugins.csv.discover_dialect(sample, encoding=encoding)<EOL><DEDENT>elif isinstance(dialect, six.text_type):<EOL><INDENT>dialect = csv.get_dialect(dialect)<EOL><DEDENT>if schema is None:  <EOL><INDENT>fobj = open_compressed(input_filename, encoding=encoding)<EOL>data = list(islice(csv.DictReader(fobj, dialect=dialect), samples))<EOL>schema = rows.import_from_dicts(data).fields<EOL>if force_types is not None:<EOL><INDENT>schema.update(force_types)<EOL><DEDENT><DEDENT>reader = csv.reader(<EOL>open_compressed(input_filename, encoding=encoding), dialect=dialect<EOL>)<EOL>header = make_header(next(reader))  <EOL>table = rows.Table(fields=OrderedDict([(field, schema[field]) for field in header]))<EOL>table._rows = reader<EOL>return rows.export_to_sqlite(<EOL>table,<EOL>output_filename,<EOL>table_name=table_name,<EOL>batch_size=batch_size,<EOL>callback=callback,<EOL>)<EOL>
Export a CSV file to SQLite, based on field type detection from samples