Name: ecto_export
Owner: xerions
Description: null
Created: 2015-07-08 10:38:40.0
Updated: 2018-02-21 07:53:33.0
Pushed: 2015-09-09 10:35:45.0
Homepage: null
Size: 169
Language: Elixir
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
An elixir application for exporting/importing data from an ecto based application.
Add ecto_export es dependeny to your applications mix.exs file:
ecto_export, github: "xerions/ecto_export"}
Start an Export job by calling Ecto.Export.create, filename must currently be provided.
cto.Export.create(Repo, [MyModel1, MyModel2], %{"filename" => "export.json"})
, 1}
When exporting, dependencies between exported Models are handled by ecto_export. The depending Model will only be contained in the output after the “parent” model.
Start an Import job by calling Ecto.Export.create, filename must currently be provided.
cto.Export.create(Repo, [MyModule1, MyModule2], %{"filename" => "export.json", "import" => true})
, 2}
Check for the status of a running job:
cto.Export.check(1)
, {:read_file, 7}}
timer.sleep(5000)
cto.Export.check(1)
, :job_finished}
The jobs progress is the stage (:read_file/:write_file) and the number of objects/lines already processed (7). When the job has finished {:ok, :job_finished} is returned.
Stop job:
cto.Export.stop(2)
cto.Export.check(2)
, :job_finished}
For further information, use the documentation which is provided in the sourcecode and available through elixir introspection.
Which formatter to use for Export/Import is specified with the “formatter” option. Default is Ecto.Export.Formatter.JSON.
To provide a customized formatter, a module must be implemented containing the following two functions:
The arguments object_stream and string_stream provide the objects/strings to be exported/imported. A customized formatter should consume the streams while outputting strings through the filehandle or objects through the Ecto.Repo. By consuming the streams the jobs progress will be updated.