4
rant1ng
6y

So, I rarely ask questions, I usually find the answer myself, but, I'm just tired today and maybe my fellow dev ranters can help here.

Is there a way to write a bash script that automatically runs a pre-defined mysql query on local DB and throws that up into production DB?

it's just a simple select and then insert.

Been looking at select into out file, from infile etc

I could do it manually, but I'm going to have to do this more than a few times over the next few weeks and would love to just alias it and be done with it

doesn't seem possible without actually logging into mysql cli each time...on both sides, which sucks

this isn't export/import a table, it's export/import the result of a query

thanks

Comments
  • 3
    I don’t know if it’s possible in bash. I’d probably do it in python
  • 1
    @not-sure yeah.... I guess, lol

    blah
  • 1
    @oudalally man I hope so.. I'll give this a try later and let you know
  • 0
    @oudalally @bitwise

    Just like I suspected, this task took like a whole day.

    I was able to export the query into a tab delimited file, but I couldn't find a way to import that same data as inserted new rows, so I gave up

    tried to create a console command that would do it, got some weird error where like, half of my data disappears or does'nt get imported

    so I'm giving up on that method and going back to importing from tab delimitmed file, with first row being the column labels

    what's the command for that?

    I tried for literally almost 2 days now to do this myself, lol time to throw in the towel
  • 0
    @Bitwise I just created a php script that converted it to MySQL then imported that on production side

    So much time wasted lol, I can't believe not an easier way, either you have to drive into MySQL conf, or just lots of dead ends... Shoulda been Lot of easier.. And the PHP or Python way I tried in the beginning should have worked, just one of those things I guess
Add Comment