io

Database data/Local File I/O module.

sqlalchemy_mate.io.sql_to_csv(sql, engine, filepath, chunksize=1000, overwrite=False)[source]

Export sql result to csv file.

Parameters:
  • sqlsqlalchemy.sql.selectable.Select instance.
  • enginesqlalchemy.engine.base.Engine.
  • filepath – file path.
  • chunksize – number of rows write to csv each time.
  • overwrite – bool, if True, avoid to overite existing file.

中文文档

将执行sql的结果中的所有数据, 以生成器的方式(一次只使用一小部分内存), 将 整个结果写入csv文件。

sqlalchemy_mate.io.table_to_csv(table, engine, filepath, chunksize=1000, overwrite=False)[source]

Export entire table to a csv file.

Parameters:
  • tablesqlalchemy.Table instance.
  • enginesqlalchemy.engine.base.Engine.
  • filepath – file path.
  • chunksize – number of rows write to csv each time.
  • overwrite – bool, if True, avoid to overite existing file.

中文文档

将整个表中的所有数据, 写入csv文件。