开始学python 交互MySQLdb,踩了很多坑

第一个

%d format: a number is required, not str

参照以下博客:

https://blog.csdn.net/u011878172/article/details/72599120

# -*- coding: utf-8 -*-

import MySQLdb

try:

conn=MySQLdb.connect(host='localhost',port='3306',db='test',user='root',passwd='toor',charset='utf-8')

csl=conn.cursor()

count=csl.execute("inser into stu(stu_id,stu_name,stu_phone,stu_hometown) values('0003','kj','19564832601',河北)")

print count

conn.commit()

csl.close()

conn.close()

except Exception,e:

print e.message

an integer is required (got type str)

port=3306即可

(1129, "Host '192.168.65.1' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'")

mysql -u root -p 进入数据库

show variables like 'max_connect_errors';

查看最大连接数

set global max_connect_errors = 1000;

修改max_connect_errors的值:

(3)查看是否修改成功

> show variables like '%max_connect_errors%';

解决方法2:使用mysqladmin flush-hosts 命令清理一下hosts文件

(1)在查找到的目录下使用命令修改:mysqladmin -u xxx -p flush-hosts

或者

> flush hosts;

解决方法3:重启mysqld

也可以在重启之前,在配置文件中将该参数调大。

# vi /etc/my.cnf

max_connect_errors = 100

python与mysql交互中的各种坑的更多相关文章

  1. Python与Mysql交互

    #转载请联系 在写内容之前,先放一张图,bling- 这张图算是比较详细的表达出了web开发都需要什么.用户访问网页,就是访问服务器的网页文件.这些网页文件由前端工程师编写的.服务器通常用nginx/ ...

  2. 二十、Python与Mysql交互

    先安装一个python与MySQL交互的包:MySQL-python $ gunzip MySQL-python-1.2.2.tar.gz $ tar -xvf MySQL-python-1.2.2. ...

  3. Python使用Mysql过程中一些错误

    Python使用Mysql过程中一些错误 ssh登录远程服务器 ssh ubuntu@xxx.xxx.xx.xx 第一:ubuntu终端中登录Mysql mysql -uroot -p 然后输入密码即 ...

  4. MySQL之Python与Mysql交互

    一:Python操作MySQL步骤 1:Python中操作MySQL的步骤 2.引入模块 在.py文件中引入pymysql模块 import pymysql pymysql是python的一个第三方与 ...

  5. python与C交互中传入与读取内存空间

    使用用python调用c代码中,从外部传入一个固定大小的内存空间,这段内存需要是可写的 首先看下c中的函数 typedef struct ModelData { unsigned int model_ ...

  6. python往mysql数据库中写入数据和更新插入数据

    本文链接:https://blog.csdn.net/Mr__lqy/article/details/85719603 1. 连接mysql import pymysql db = pymysql.c ...

  7. Python连接MySQL数据库中各种坑

    第一个坑 要想连接数据库,我们必须拥有MySQL-python这个模块,首先,我在安装这个模块的时候就到了第一个大坑. 常规安装方法:进入cmd 使用 pip install MySQL-python ...

  8. python 往mysql数据库中插入多条记录。

    最近想写mysql库,用到insert into语句,如何一次性将多条记录插入库表中呢. MySQLdb提供了两个执行语句的方法:一个是execute(),另一个是executemany() exec ...

  9. python 将mysql数据库中的int类型修改为NULL 报1366错误,解决办法

    gt.run_sql()是用pymysql 封装的类 distribution_sort_id type: int目的:将此字段值全部修改为NULL g=2gt.run_sql("updat ...

随机推荐

  1. Confluence 6 关于 Decorators

    Confluence 是使用开源的 SiteMesh 库构建的.一个 Web 页面的布局系统,这个布局系统能够在全站点中提供完整统一的界面和外观.SiteMesh 是通过 "decorato ...

  2. deepin 桌面突然卡死

    deepin桌面突然卡死 使用快捷键Ctrl+alt+F2 重启systemctl

  3. sublime c++

    install: sudo add-apt-repository ppa:webupd8team/sublime-text-3   sudo apt-get update sudo apt-get i ...

  4. MySQL数据库下载、安装

    地址:https://www.mysql.com/ 解压下载的文件 配置环境变量 新建系统变量 变量名:MYSQL_HOME 变量值:解压  mysql-5.7.24-winx64.zip  后的路径 ...

  5. 五.Bash Shell编程基础入门实战

    知识回顾 运行脚本我们一般用sh 不用单独去加执行权限 OLDBOY=10只适用当前环境 局部变量 export OLDBOY把它设置为临时的环境变量应为已经=10了所以不用export OLDBOY ...

  6. 异常小结:上一张图搞清楚Java的异常机制

    下面是Java异常类的组织结构,红色区域的异常类表示是程序需要显示捕捉或者抛出的. Throwable Throwable是Java异常的顶级类,所有的异常都继承于这个类. Error,Excepti ...

  7. 数据增强(每10度进行旋转,进行一次增强,然后对每张图片进行扩充10张patch,最后得到原始图片数*37*10数量的图片)

    # -*- coding: utf-8 -*-"""Fourmi Editor This is a temporary script file.""& ...

  8. The error may exist in com/bjpowernode/dao/StudentDao.xml ### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderExcept

    The error may exist in com/bjpowernode/dao/StudentDao.xml### Cause: org.apache.ibatis.builder.Builde ...

  9. Python - 去除list中的空字符

    list1 = ['122', '2333', '3444', '', '', None] a = list(filter(None, list1)) # 只能过滤空字符和None print(a) ...

  10. 用C语言实现窗口抖动

    #include "stdafx.h" #include <stdio.h> #include<Windows.h> int main() { ; //休眠 ...