Is there a way to import a 10mb plain sql file in ecto?
why do you need to use Ecto for that? Can’t you use
I can upload it directly from MariaDB, but I was trying to automate this import through the seeds file, is it possible or I have to do i manually?
Ah, I know nothing about MySQL/MariaDB and Ecto’s driver. Maybe there is some way to hack it around but I don’t want to mislead you. You could call a system command from your seed script however.
I will try placing the whole plain sql and import it (I already know how to import a query but I wanted to import a whole file)
You can fire a plain SQL request with Ecto (this code is dependent on version 2):
alias Ecto.Adapters.SQL querystring = File.read!("file.sql") result = SQL.query(Repo, querystring , )
does it actually work with multiple statements?
I don’t have the slightest idea I wouldn’t be surprised that it is not the case, but I can’t test it at the moment
I will check it in a moment, I assume that it will work for a 10mb file with many multiple statements
Again, I know nothing about Maria/MySQL driver, but I would not be surprised if it would not work and allowed you to do single statement/query only.
Maybe you could use
mix ecto.load - it loads from
priv/structure.sql by default
Which does call “mysql” shell command behind the scenes. So, most likely, you need to do the same.
Thanks benperiton, the answer was correct:
mix ecto.load -d "my.sql"