nowphp

导航

 

wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz

cd Python-3.5.2

./configure --prefix=/usr/local/python3.5.2

make -j4 && make install

vi ~/.bash_profile

+ /usr/local/python3.5.2/bin

. ~/.bash_profile

 

mysql:

yum install MySQL-python

import MySQLdb

 

 

python 小程序

#coding=utf-8
import MySQLdb

conn= MySQLdb.connect(
        host='localhost',
        port = 3306,
        user='root',
        passwd='Hisoft@1',
        db ='test',
        )
cur = conn.cursor()

#创建数据表
#cur.execute("create table student(id int ,name varchar(20),class varchar(30),age varchar(10))")

#插入一条数据
cur.execute("insert into account(name,passwd) values('test','passwd')")


#修改查询条件的数据
#cur.execute("update student set class='3 year 1 class' where name = 'Tom'")

#删除查询条件的数据
#cur.execute("delete from account where id='9'")

#获得表中有多少条数据
aa=cur.execute("select * from account")
print aa

#打印表中的多少数据
info = cur.fetchmany(aa)
for ii in info:
    print ii

cur.close()
conn.commit()
conn.close()

  

posted on 2016-09-30 17:03  不断成长  阅读(168)  评论(0编辑  收藏  举报