#coding=utf-8
import MySQLdb
conn = MySQLdb.Connect(host = '127.0.0.1',port=3306,user='root',passwd='',db='test',charset='utf8')
cursor = conn.cursor() try:
#插入数据
sql_insert = "insert into orders(order_id,product_id) values (777,777)"
cursor.execute(sql_insert)
print cursor.rowcount #修改数据
sql_update = "update orders set order_id = 99999 where id=12"
cursor.execute(sql_update)
print cursor.rowcount #删除数据
sql_delete = "delete from orders where id = 3"
cursor.execute(sql_delete)
print cursor.rowcount #提交
conn.commit()
except Exception as e:
print e
conn.rollback() #关闭指针和连接
cursor.close()
conn.close()

python常用sql语句的更多相关文章

  1. Mysql 常用 SQL 语句集锦

    Mysql 常用 SQL 语句集锦 基础篇 //查询时间,友好提示 $sql = "select date_format(create_time, '%Y-%m-%d') as day fr ...

  2. Mysql 常用 SQL 语句集锦 转载(https://gold.xitu.io/post/584e7b298d6d81005456eb53)

    Mysql 常用 SQL 语句集锦 基础篇 //查询时间,友好提示 $sql = "select date_format(create_time, '%Y-%m-%d') as day fr ...

  3. 50个常用SQL语句

    50个常用SQL语句 Student(S#,Sname,Sage,Ssex) 学生表  S#学号,主键 Course(C#,Cname,T#) 课程表          C#课程号,主键 SC(S#, ...

  4. oracle sqlplus及常用sql语句

    常用sql语句 有需求才有动力 http://blog.csdn.net/yitian20000/article/details/6256716 常用sql语句 创建表空间:create tables ...

  5. oracle常用SQL语句(汇总版)

    Oracle数据库常用sql语句 ORACLE 常用的SQL语法和数据对象一.数据控制语句 (DML) 部分 1.INSERT (往数据表里插入记录的语句) INSERT INTO 表名(字段名1, ...

  6. 常用SQL语句(增删查改、合并统计、模糊搜索)

    转自:http://www.cnblogs.com/ljianhui/archive/2012/08/13/2695906.html 常用SQL语句 首行当然是最基本的增删查改啦,其中最重要的是查. ...

  7. oracle 常用sql语句

    oracle 常用sql语句 1.查看表空间的名称及大小 select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_sizefrom d ...

  8. Sqlite常用sql语句

    sqlite常用sql语句 --返回UTC时间 select CURRENT_TIMESTAMP; --返回本地时间 select datetime(CURRENT_TIMESTAMP,'localt ...

  9. 常用SQL语句集合

    一.数据定义 1.创建新数据库:CREATE DATABASE database_name2.创建新表:CREATE TABLE table_name (column_name datatype,co ...

随机推荐

  1. wget的使用详解

    我在工作中, 经常下载遥感影像,每个影像都很大,使用普通的ftphelpe下载不太稳定,最终选择了linux下一款牛逼的下载工具wget,使用它的windows移植版本的.在此写此文,希望对和我一样保 ...

  2. 关于ajax提交表单参数序列化和时间戳转换

    ajax提交form表单, 序列化表单的参数 //var a = $("#addfm").serialize(); //将表单的内容序列化成为一个字符串 var a = $(&qu ...

  3. thymeleaf 中文乱码问题

    使用thymeleaf后,即使使用org.springframework.web.filter.CharacterEncodingFilter也不能解决中文乱码问题了, 后来发现在org.thymel ...

  4. 用过的一个jquery插件实现转盘效果还不错手机兼容

    (function($) {var supportedCSS,styles=document.getElementsByTagName("head")[0].style,toChe ...

  5. equals(==),toString

    equals/==: 只有指向同一个对象是,才返回true. 特殊: String s1 = new String("hello"); String s2 = new String ...

  6. Multi-line NSAttributedString with truncated text

    http://stackoverflow.com/questions/7611816/multi-line-nsattributedstring-with-truncated-text/1017279 ...

  7. [转]深入理解mysqldump原理 --single-transaction --lock-all-tables --master-data

    本文转至:http://blog.csdn.net/cug_jiang126com/article/details/49824471 在mysqldump过程中,之前其实一直不是很理解为什么加了--s ...

  8. RMQ_ST算法

    RMQ (Range Minimum/Maximum Query)算法 1. 概述 RMQ(Range Minimum/Maximum Query),即区间最值查询,是指这样一个问题:对于长度为n的数 ...

  9. BZOJ3175 Tjoi2013 攻击装置(二分图匹配)

    传送门 Description 给定一个01矩阵,其中你可以在0的位置放置攻击装置.每一个攻击装置(x,y)都可以按照"日"字攻击其周围的 8个位置(x-1,y-2),(x-2,y ...

  10. bzoj 1064

    题意:戳这里 思路:很明显是一个图论模型.. 就两种图形: 1.图中存在环,那么就是所有环的gcd为最大答案.gcd的大于3的最小约数为最小答案 2.不存在环,那么是每个弱连通块的最长链之和为最大答案 ...