Skip to content

Instantly share code, notes, and snippets.

@Stiivi
Created January 9, 2013 21:28
Show Gist options
  • Save Stiivi/4497118 to your computer and use it in GitHub Desktop.
Save Stiivi/4497118 to your computer and use it in GitHub Desktop.
import brewery.stores as stores
filename = "data.csv"
source = stores.CSVDataSource(filename, encoding="latin1", infer_fields=True,
read_header=True)
target = stores.SQLDataTarget(url="sqlite:///data.sqlite",
table="data", create=True, fields=source.fields,
replace=True)
target.append_from(source)
target.flush()
import brewery.stores as stores
filename = "data.csv"
source = stores.CSVDataSource(filename, encoding="latin1", infer_fields=True,
read_header=True)
target = stores.SQLDataTarget(url="sqlite:///data.sqlite",
table="data", create=True, fields=source.fields,
replace=True)
for row in source.rows()
target.append(some_transformation(row))
target.flush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment