• pyodbc:Python使用pyodbc访问数据库操作方法


    之前介绍过很多种python访问数据库的方法,例如create_engine。。还有pyssl等等。。

    此外,还有一种pyodbc的方法。

    Python使用pyodbc访问数据库操作方法详解:https://www.jb51.net/article/143212.htm

    无法预定义语句

    这个错误实际上在之前有遇到过。。当时是怎么解决的呢。。好像是把数据类型修改了一下:https://www.cnblogs.com/2008nmj/p/15047692.html

    sqlalchemy.exc.ProgrammingError: (pyodbc.ProgrammingError) ('42S22', "[42S22] [Microsoft][SQL Server Native Client 11.0][SQL Server]列名 'contact_name' 无效。 (207) (SQLExecDirectW); [42S22] [Microsoft][SQL Server Native Client 11.0][SQL Server]无法预定义语句。 (8180)") [SQL: 'SELECT TOP 1 users.id AS users_id, users.username AS users_username, users.password_hash AS users_password_hash, users.contact_name AS users_contact_name, users.email AS users_email, users.phone AS users_phone, users.disabled AS users_disabled, users.realname AS users_realname, users.groupid AS users_groupid, users.roleids AS users_roleids, users.company_id AS users_company_id, users.valid_time AS users_valid_time, users.level AS users_level, users.create_time AS users_create_time, users.update_time AS users_update_time FROM users WHERE users.username = ?'] [parameters: ('gaochun',)] (Background on this error at: http://sqlalche.me/e/f405)

    >>怎么生成md5码:怎么加密

    import hashlib
    
    
    def get_hash(s):
        if s is not '':
            return hashlib.md5(s.encode(encoding='UTF-8')).hexdigest()
        else:
            return s
    
    
    def verify(value, hashvalue):
        h = hashlib.md5(value.encode(encoding='UTF-8')).hexdigest()
        if h == hashvalue:
            return True
        else:
            return False
    
    if __name__ == '__main__':
        s1 = '123';
        s2 = get_hash(s1);
        print(s2);

    参考:https://www.cnblogs.com/2008nmj/p/13856121.html

    dbo.users

    如果把mssql+pymssql://sa:xxx@localhost:1433/sss换成myssql+pyodbc://sa:xxx@.....

    找到原因了。。默认数据库没有配置。。

  • 相关阅读:
    http返回码
    WCF 超时
    MVC异步
    熔断设计模式
    JAVA学习图
    java io模型
    keep alive 长连接
    Java异常处理 误区
    架构的本质
    Repository模式
  • 原文地址:https://www.cnblogs.com/2008nmj/p/15078378.html
Copyright © 2020-2023  润新知