Menu

how can I connect mysql in pipe

devuser
2005-09-26
2012-09-19
  • devuser

    devuser - 2005-09-26

    mysql.exe --socket="C:\Program Files\Global 360\Reports Manager Server\bin\colds
    qld.sock" --protocol=pipe

    I can call mysql.exe to connect with mysql correctly.

    how can I connect with mysql with mysqldb

     
    • devuser

      devuser - 2005-09-27

      Dear

      I connect mysql ok with your recommended method.

      I write a file as my_app.cnf.

      thanks.

       
    • Andy Dustman

      Andy Dustman - 2005-09-26
       
    • devuser

      devuser - 2005-09-26

      Dear ajustman

      how can I invoke the connect function

      do I invoke connect as flowed conrrectly ?

      db = MySQLdb.connect(host="localhost", user="root", passwd="", db="ReportsMgmtDb",named_pipe="C:\Program Files\Global 360\Reports Manager Server\bin\colds
      qld.sock")

      or

      how can I get the pipe of mysql in windows ?

       
      • Andy Dustman

        Andy Dustman - 2005-09-26

        I do not think you need to supply host. Also, for the backslashes to be interpreted correctly, you should use a raw string, i.e.:

        db = MySQLdb.connect(user="root", passwd="", db="ReportsMgmtDb",named_pipe=r"C:\Program Files\Global 360\Reports Manager Server\bin\coldsqld.sock")

        Note the letter 'r' in front of your string. This is a signal to the Python parser that the following string is a raw string, which means that backslash has no special meaning.

        Also, I recommend using the read_default_file option. You can point this at a file containing:

        [ReportsMgmt]
        user = root
        password =
        db = ReportsMgmtDb
        protocol = PIPE
        socket = C:\Program Files\Global 360\Reports Manager Server\bin\coldsqld.sock

        and reduce your connect() call to:

        db = MySQLdb.connect(read_default_file="my_app.cnf", read_default_group="ReportsMgmt")

        Be aware that I do no MySQL work in Windows, so this is all guesswork on my part.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.