百里屠苏top  

参考引用博客:http://www.cnblogs.com/wupeiqi/articles/5713330.html

ifconfig是linux中用于显示或配置网络设备(网络接口卡)的命令,英文全称是network interfaces configuring。

在winxp中没有“ifconfig”这个命令。当然就会提示“不是内部或者外部命令,也不是可运行的程序”。

在winxp中,有个cmd下使用的命令应该是“ipconfig”。

一. python  mysql API

 

说明:   localhost其实就是127.0.0.1,你也可以ping一下这个地址看通不通。

            数据库默认端口,不用改;

      你的数据库名字。

 

 1 import pymysql
 2 # 创建连接
 3 conn = pymysql.connect(host='127.0.0.1', port=3306, user='root', passwd='*******', db='xiaolazi')
 4 # 创建游标
 5 cursor = conn.cursor()
 6 #执行SQL,并返回收影响行数
 7 # effect_row = cursor.execute("select * from student")
 8 # print(effect_row)
 9 # print(cursor.fetchone())   #取出表中数据
10 # print("---" * 10)
11 # print(cursor.fetchall())   #取出表中所有数据
12 
13 data = [
14     (6,"yaoburan",19,"2019-01-03"),
15 (7,"xuyuan",17,"2019-01-14"),
16 (8,"yanyan",18,"2019-01-06"),
17 ]
18 
19 cursor.executemany("insert into student (id,name,age,register_date) values(%s,%s,%s,%s)", data) #默认开启事物,得commit,即确认才真正插入到数据表中
20 conn.commit()
21 effect_row = cursor.execute("select * from student")
22 print(cursor.fetchall())   #取出表中所有数据
23 # 关闭游标
24 cursor.close()
25 # 关闭连接
26 conn.close()

 

posted on 2019-01-13 15:20  百里屠苏top  阅读(198)  评论(0编辑  收藏  举报