Skip to main content

Creating db and import sql in script hook

Comments

5 comments

  • cPanelLauren
    hi @binooetomo Why are you calling <./master_sql.sql ? The database name is gijilint_wp_20181008203558 unless there's a table in the db with that name it's not going to come up and from your creation of the database I don't see it being created. Thanks!
    0
  • binooetomo
    hi @binooetomo Why are you calling <./master_sql.sql ? The database name is gijilint_wp_20181008203558 unless there's a table in the db with that name it's not going to come up and from your creation of the database I don't see it being created. Thanks!

    First, thankyou @cPanelLauren for your response. From my script log (I re run the script, it already call ' mysql -D kupretin_wp_20181009205940 <./master_sql.sql and still got the same error code : ERROR 1049 (42000): Unknown database '<./master_sql.sql' Actualy, before the import part ... my script do a double check to make sure if target database is ready. ' Here is a snip of it dbcheck = 'mysqlshow %s' %(dbname) dbcheck = dbcheck.split() while True : try : p = subprocess.Popen(dbcheck, stdout=subprocess.PIPE) presult=p.communicate() assert presult[0].split('|')[0].split(':')[0]=='Database' break except Exception as e : time.sleep(1) sqljob='mysql -D %s <./master_sql.sql' %(dbname) writelog(sqljob) sqljob=sqljob.split() p = subprocess.Popen(sqljob, stdout=subprocess.PIPE) results= p.communicate() writelog(str(presult))
    0
  • cPanelLauren
    Hi @binooetomo The part I am not understanding though is why you're referencing a table in the database that doesn't exist. This will never work unless master_sql.sql exists. I'm not understanding the end goal you're looking to accomplish either and maybe understanding that will help. Thanks!
    0
  • binooetomo
    Dear @cPanelLauren Thankyou for your response. First I Apologize for this. This is My vault. I learn more about playing with python's subprocess.Popen and it fixed the problem. That is ... the working code should : myinput=open('master_sql.sql') sqljob='mysql -D %s ' %(dbname) writelog(sqljob) sqljob=sqljob.split() p = subprocess.Popen(sqljob, stdin=myinput, stdout=subprocess.PIPE) Sincerely -bino-
    0
  • cPanelLauren
    Hi @binooetomo I'm glad you were able to get the issue resolved and thank you for updating the thread!
    0

Please sign in to leave a comment.