美文网首页
Parse SQL with Python

Parse SQL with Python

作者: clavichord99 | 来源:发表于2016-03-30 14:19 被阅读0次

    Basic info

    User pypyodbc.
    Simple example for accessing mssql
    Compatibility with pyodbc can be found here

    pip3 install pypyodbc

    Sample code

    DatabaseString = "NJDKMonitor2"
    ConnectionString = "DRIVER={SQL Server}; SERVER=192.168.1.109; UID=geomos_admin2; PWD=geomos_admin_2006; DATABASE=" +  DatabaseString
    Conn = pypyodbc.connect(ConnectionString)
    #CustomText1 as Point Group
    SQLString = """
             Select Result.CustomText1, Result.PointNo,Result.ProfileName, Result.Time, Result.TargetEasting, Result.TargetNorthing, Result.TargetElevation
             From PointReportView Result
             Where DATEDIFF(hour, Result.Time, getdate())<24
             Order by Result.Time DESC
            """
    Cur = Conn.cursor()
    Cur.execute(SQLString)

    相关文章

      网友评论

          本文标题:Parse SQL with Python

          本文链接:https://www.haomeiwen.com/subject/chtelttx.html