3 Replies Latest reply on May 16, 2018 3:17 PM by tramachandran

    python PI SQL DATA ACCESS

    epotencia

      Hi, I wanted access a osisoft database with python but I compiled the program and the resut was:

       

      #python -m py_compile example.py

      #vi example.py

      #!/usr/bin/python

      import jaydebeapi

      conn = jaydebeapi.connect("com.osisoft.jdbc.Driver","jdbc:piintegrator://10.36.15.47/",{'user':

      "test_user", 'password': "pwd_user", 'ProtocolOrder' : "Https/Soap:5461,

      NetTcp:5462"},":/opt/pipc/jdbc/PIJDBCDriver.jar",)

      curs= conn.cursor()

      a.curs.execute("select * from my_view ")

      pi_data_list= curs.fetchall()

      for pi_data in pi_data_list:

          print(pi_data)

      a.curs.close()

      b.conn.close()

       

      And the result was:

      # python -m py_compile example.py

        File "example.py", line 4

          "test_user", 'password': "pwd_user21", 'ProtocolOrder' : "Https/Soap:5461,

                                                                            ^

      SyntaxError: EOL while scanning string literal

       

      Could you help me find the error please?

       

      Regards.

        • Re: python PI SQL DATA ACCESS
          Eugene Lee

          Hi Xo,

           

          Why are you not using the PI Web API client library for Python?

          • Re: python PI SQL DATA ACCESS
            epotencia

            Hi, good morning Eugenee, this is the first time that I will use python for access osisoft DAS server. I tried to use Perl but I field unfortunable. Now, I read the community advices with Python so, I will use Python but I don't how to use it.

             

            With Perl, firts step was run a server  DBD:JDC and second step the client, but I didn't successful conexion whit the Perl client.

            So I decided use Python, I don't how use it for make a conecction, Will I start to use Python beacause I read is a fantastic languaje, I hope you can give your help for use it.

             

            I don't know how connect to osisoft DAS server, for this reason I didn't use PI Web API client library.

             

            Please, will you help me with that?

             

            Thanks a lot.

             

            Regards.

            Xóchitl

              • Re: python PI SQL DATA ACCESS
                tramachandran

                First the syntax error in your Python code is due to the string formatting, which spans multiple lines in the connect method.

                For line breaks you can use the \ or other methods suggested in the PEP 8 guide.

                Example string s spanning multiple lines.

                 

                For the second part, I am a little confused with your whole argument of zeroing in on the language and developer technology to access PI System data. If you could provide us with more details on what you are trying to accomplish we might be able to guide you in a better manner. I would also recommend contacting us through our support to help us understand your situation better and figure out the best solution.