python08_05day
#!/usr/bin/python
# -*- coding: UTF-8 -*-
from _ast import Param
#查询数据库
'''
import MySQLdb
conn = MySQLdb.connect(host='127.0.0.1',user='root', passwd='1234', db='08day05')
cur = conn.cursor()
reCount = cur.execute('select * from userinfo')
data = cur.fetchall()
cur.close()
conn.close()
print reCount
print data
'''
#插入数据
'''
import MySQLdb
conn = MySQLdb.connect(host='127.0.0.1',user='root', passwd='1234', db='08day05')
cur = conn.cursor()
sql = "insert into userinfo (name ,address) values(%s,%s)"
params = ('wang','use')
reCount = cur.execute(sql, params)
conn.commit()
#data = cur.fetchall()
cur.close()
conn.close()
print reCount
'''
#删除数据
'''
import MySQLdb
conn = MySQLdb.connect(host='127.0.0.1',user='root', passwd='1234', db='08day05')
cur = conn.cursor()
sql = "delete from userinfo where id = %s"
params = ('8')
reCount = cur.execute(sql, params)
conn.commit() #需要提交,语句才能生效
#data = cur.fetchall()
cur.close()
conn.close()
print reCount
'''
#更新数据
'''
import MySQLdb
conn = MySQLdb.connect(host='127.0.0.1',user='root', passwd='1234', db='08day05')
cur = conn.cursor()
sql = "update userinfo set name = %s where id =4"
params = ('www')
reCount = cur.execute(sql, params)
conn.commit() #需要提交,语句才能生效
#data = cur.fetchall()
cur.close()
conn.close()
print reCount
'''
#批量插入数据
'''
import MySQLdb
conn = MySQLdb.connect(host='127.0.0.1',user='root', passwd='1234', db='08day05')
cur = conn.cursor()
li = [
('alax','feifie'),
('wangba','dagou'),
('wangba','dagou'),
('wangba','dagou'),
('wangba','dagou'),
('wangba','dagou'),
('wangba','dagou'),
('wangba','dagou'),
('wangba','dagou'),
]
reCount = cur.executemany('insert into userinfo(name,address ) values(%s,%s )',li)
conn.commit() #需要提交,语句才能生效
#data = cur.fetchall()
cur.close()
conn.close()
print reCount
'''
#把ID 义字典的形式读取出来
'''
import MySQLdb
conn = MySQLdb.connect(host='127.0.0.1',user='root', passwd='1234', db='08day05')
cur = conn.cursor(cursorclass = MySQLdb.cursors.DictCursor)
reCount = cur.execute('select * from userinfo')
data = cur.fetchall()
cur.close()
conn.close()
print reCount
print data
'''
'''
import MySQLdb
conn = MySQLdb.connect(host='127.0.0.1',user='root', passwd='1234', db='08day05')
cur = conn.cursor()
#cur = conn.cursor(cursorclass = MySQLdb.cursors.DictCursor)
reCount = cur.execute('select * from userinfo')
#data = cur.fetchall()
data = cur.fetchone()
print data
#cur.scroll(0,mode='absolute')
data = cur.fetchone()
print data
cur.scroll(-1,mode='relative')
data = cur.fetchone()
#cur.scroll(0,mode='absolute')
cur.close()
conn.close()
#print reCount
print data
'''
import MySQLdb
conn = MySQLdb.connect(host='127.0.0.1',user='root', passwd='1234', db='08day05')
cur = conn.cursor()
sql = "insert into userinfo (name ,address) values(%s,%s)"
params = ('wang','use')
reCount = cur.execute(sql, params)
conn.commit()
#data = cur.fetchall()
cur.close()
conn.close()
print reCount
随机推荐
- UE5 打不开
在游戏开发中,出现了UE打不开的情况 初步推测,新增了接口Attacker, 而我们的DefaultPawn可能一下子实现了两个接口造成的 而这两个接口都在一个插件里,一个是c++实现的,一个是蓝图实 ...
- 20+前端常用的vscode插件(总结推荐)
本篇文章给大家总结分享20多个前端常用的vscode插件.有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助. 1. vscode 简介vscode是微软开发的的一款代码编辑器,就如官网上 ...
- 解锁 SQL Server 2022的时间序列数据功能
解锁 SQL Server 2022的时间序列数据功能 SQL Server2022在处理时间序列数据时,SQL Server 提供了一些优化和功能,比如 DATE_BUCKET 函数.窗口函数(如 ...
- python解决urllib发送请求报错:urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:xxxx)>
在使用urllib.request.Request(url)前,添加代码放到最前面 import ssl ssl._create_default_https_context = ssl._create ...
- SecureCRT通过vbs脚本实现自动化登录linux服务器
1.配置登录主机名.用户和密码 2.配置登录后操作脚本目录 3.vbs操作脚本如下(crt也支持python) #$language = "VBScript" #$interfac ...
- 【MySQL】LEFT JOIN 踩坑
一.问题发现: 主查询功能发现两条一样的记录,但是审批状态不一样,一个已通过,一个待审核 主表付款表: CREATE TABLE `pur_or_payment` ( `id` int(11) NOT ...
- 【Centos】RPM安装Mysql8
先去官网下载RPM包,没想到RPM包是红帽发行版 https://dev.mysql.com/downloads/mysql/ 使用wget直接下载到Centos里面: wget https://cd ...
- 一款比较好用的 ssh、 ftp 服务的客户端软件 —— NxShell
该软件地址: https://gitee.com/nxshell/nxshell 截图: ======================================================= ...
- 外网的一个还不错的高性能计算教程: High Performance Computing
地址: https://info.gwdg.de/wiki/doku.php?id=wiki:hpc:start =========================================== ...
- 部署MatterMost-开源团队协作平台
前言 之前的文章有提到部署 MatterMost 的事. 本文来记录一下. 关于 MatterMost MatterMost 有点像 Slack 这种协作工具,而且和 GitLab 的集成还不错,正好 ...