Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

db:import from stdin #154

Closed
maxbucknell opened this issue Nov 26, 2015 · 5 comments
Closed

db:import from stdin #154

maxbucknell opened this issue Nov 26, 2015 · 5 comments

Comments

@maxbucknell
Copy link

I want to load a database and pass it to an import without going through a file. For example

n98-magerun2 db:dump -c gzip --strip="@development" --stdout | \
n98-magerun2 db:import -c gzip --drop /dev/stdin

This worked, but the command didn't terminate properly after the command ended. I was unable to type at my terminal, and I had to exit and re-enter, at which point everything was fine.

Given you don't have an option in db:import for reading stdin, I'm guessing this is not a supported use case?

@tkn98
Copy link
Collaborator

tkn98 commented Nov 26, 2015

Good question. db:import is merely a wrapper to exec the mysql program. It should be an easy test if this works when the filename parameter is made optional (try with a quick hack). Otherwise in your case it seems that end-of-file is not detected via /dev/stdin which makes sense as the handle is still open even if no more data is "passed via pipe".

So far I don't understand fully why this happens what you describe.

ktomk added a commit that referenced this issue Nov 27, 2015
minor fixes in review of #154
@ktomk
Copy link
Collaborator

ktomk commented Nov 27, 2015

@maxbucknell: The db:import needs to be changed from exec to passthru, that could work. /dev/stdin as $fileName could trigger this. Ref: https://github.com/netz98/n98-magerun2/blob/develop/src/N98/Magento/Command/Database/ImportCommand.php#L194

And -c gzip doesn't make sense with the pipe (I think).

@maxbucknell
Copy link
Author

It's worth mentioning that the import worked perfectly. My database was imported as I expected, and it's not fair to say I couldn't type.

@ktomk The example is a silly example. What I was actually doing was dumping a file on a server and curling it and piping it in. In this case, gzip saves some bites. I love that gzip is streamable.

@tkn98
Copy link
Collaborator

tkn98 commented Nov 30, 2015

Yes, piping is a good option. I'll run some test for PHP in general to see how this can work. IIRC exec and friends in PHP create subshells and I want to check if it's working before implementing anything.

@cmuench cmuench closed this as completed Dec 30, 2019
@iaugusto-ironplane
Copy link

Related: netz98/n98-magerun#934

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants