zoukankan      html  css  js  c++  java
  • python 基础 9.12 索引

    #/usr/bin/python
    #-*- coding:utf-8 -*-
    #@Time   :2017/11/24 4:48
    #@Auther :liuzhenchuan
    #@File   :索引.py
     
    import MySQLdb
     
    # 把分数小于5分的成绩都加6分
    sql = '''alter table score add index idx_stdid_couid(std, couid)'''
    sql1 = '''alter table score add index idx_couid_stdid(couid, std)'''
     
     
    def connect_mysql():
        db_config = {
            "host": "192.168.48.131",
            "port": 3306,
            "user": "ling",
            "passwd": "123456",
            "db": "stuteas",
            "charset": "utf8"
        }
        try:
            cnx = MySQLdb.connect(**db_config)
        except Exception as e:
            raise e
        return cnx
     
    if __name__ == "__main__":
        cnx = connect_mysql()
        cus = cnx.cursor()
        try:
            cus.execute(sql)
            result1 = cus.fetchall()
            print(result1)
     
            cus.close()
            cnx.commit()
        except Exception as e:
            cnx.rollback()
            raise e
        finally:
            cnx.close()
  • 相关阅读:
    httpclient 5.0 设置超时时间
    httpclient raw请求
    使用EasyUI-datagrid-export.js导出Excel,不导出隐藏列
    ExpressSet 虚拟适配器
    中断模式队列
    autohotkey 线程入门
    读rbtree
    树莓派串口
    MCP3421使用详解
    PMOS开关电路
  • 原文地址:https://www.cnblogs.com/lzcys8868/p/7888762.html
Copyright © 2011-2022 走看看