omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    MS SQL Driver?

    Pythonista
    6
    14
    5988
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ihf
      ihf last edited by

      Is there a driver that will permit sqlalchemy to communicate with MS SQL Server? pyodbc requires c libraries so it cannot be installed. MySQL and pymysql work fine but I need to connect to MS SQL.

      1 Reply Last reply Reply Quote 0
      • ihf
        ihf last edited by

        I found the pypyodbc driver which is pure python but when I try to import it I get this error:

        import pypyodbc
        Traceback (most recent call last):
        File "<string>", line 1, in <module>
        File "/private/var/mobile/Containers/Shared/AppGroup/05D14C00-CCAC-4E98-A3CC-96C6944B8534/Pythonista3/Documents/site-packages-2/pypyodbc.py", line 440, in <module>
        raise OdbcNoLibrary('ODBC Library is not found. Is LD_LIBRARY_PATH set?')
        pypyodbc.OdbcNoLibrary: 'ODBC Library is not found. Is LD_LIBRARY_PATH set?'

        cvp 1 Reply Last reply Reply Quote 0
        • cvp
          cvp @ihf last edited by

          @ihf seems to work only on MacOS and Linux, and to be not really "pure Python"

          1 Reply Last reply Reply Quote 1
          • ihf
            ihf last edited by

            That's too bad. It would appear there is no way to get sqlalchemy on Pythonista to connect to SQL Server.

            1 Reply Last reply Reply Quote 0
            • sulcud
              sulcud last edited by

              @ihf check this and try something similar to check if it works https://stackoverflow.com/questions/15750711/connecting-to-sql-server-2012-using-sqlalchemy-and-pyodbc

              1 Reply Last reply Reply Quote 0
              • JonB
                JonB last edited by

                pyodbc is written in c.

                I think some options would be to run a bridge program on your PC, or even something like a raspberry pi, that acts like a sql server, but just passes cursor commands/data to the mssql server.

                1 Reply Last reply Reply Quote 0
                • ihf
                  ihf last edited by

                  The drivers work with MySQL but I guess no one has seen a need for a pure python driver for MS SQL.

                  1 Reply Last reply Reply Quote 0
                  • ihf
                    ihf last edited by

                    In case anyone else has the need to use Pythonista to talk to MS SQL server, I just found and successfully tested the pure python MS SQL driver python-tds.

                    cvp 1 Reply Last reply Reply Quote 0
                    • cvp
                      cvp @ihf last edited by

                      @ihf I don't need it but that's a good news

                      1 Reply Last reply Reply Quote 0
                      • rushjob
                        rushjob last edited by

                        @ihf, I'm hoping you can point out something simple I have wrong with my python-tds install!

                        I managed to clone the sqlalchemy_pytds dir from https://github.com/m32/sqlalchemy-tds.git but and I gave pyton-tds (1.11.0) installed according to pip list in stash but when I try and run the below code:

                        import sqlalchemy
                        import sqlalchemy_tds
                        
                        from sqlalchemy import create_engine
                        
                        conn_str = 'mssql+pytds://xxx'
                        engine = create_engine(conn_str)
                        

                        I get the error:
                        The 'python-tds' distribution was not found and is required by the application.

                        Hope you have come across this error in your attempts to get pytds working for mssql on pythonista and can point me in the right direction!

                        Thanks

                        1 Reply Last reply Reply Quote 0
                        • JonB
                          JonB last edited by

                          Restart pythonista.
                          Type import pytds
                          Do you get an error?

                          If so, check that you actually installed pytds to your site-packages folder.

                          1 Reply Last reply Reply Quote 0
                          • rushjob
                            rushjob last edited by

                            Thanks for the reply. If I just test the script:

                            import pytds
                            

                            I get the same “ pkg_resources.DistributionNotFound: The 'python-tds' distribution was not found and is required by the application” error.

                            I do have the pytds folder in my site-packages -3 folder though.

                            Given the error is from the line:

                                __version__ = pkg_resources.get_distribution('python-tds').version
                            

                            In the init.py from pytds, I wonder if I’m missing that package somehow (if so, any ideas how I could get it?)

                            Thanks

                            1 Reply Last reply Reply Quote 0
                            • JonB
                              JonB last edited by

                              Oh, I see the prob. That setup.py is sort of wonky, in that it tries to run git to get the version. I'm not exactly sure what pkg_resources is pulling from, if pip is supposed to populate some database, or what, but it doesn't work in stash.

                              Since this is only failing on getting the version number, you should be able to hard code it.

                              What happens if you just replace that line in the unit with this?

                              __version__ = "1.11.0"
                              
                              1 Reply Last reply Reply Quote 0
                              • sebastianwild
                                sebastianwild last edited by

                                Hard coding the version number works a treat 🙏

                                1 Reply Last reply Reply Quote 0
                                • First post
                                  Last post
                                Powered by NodeBB Forums | Contributors