标签:
Encountered a section with no Package: header
E: Problem with MergeList /var/lib/apt/lists/dl.google.com_linux_chrome_deb_dists_stable_main_i18n_Translation-en%5fUS
E: The package lists or status file could not be parsed or opened.
#!/usr/bin/python
#coding=utf-8
import MySQLdb
conn = MySQLdb.connect(host=‘localhost‘,user=‘root‘,passwd=‘123‘)
curs = conn.cursor()
curs.execute("create database fristDb")
conn.close()
#!/usr/bin/python
#coding=utf-8
import MySQLdb
conn = MySQLdb.connect(host=‘localhost‘,user=‘root‘,passwd=‘123‘,db=‘fristDb‘)
curs = conn.cursor()
curs.execute("select version()")
data = curs.fetchone()
print "our database version: %s" % data
conn.close()
#!/usr/bin/python
#coding=utf-8
import MySQLdb
conn = MySQLdb.connect(host=‘localhost‘,user=‘root‘,passwd=‘123‘,db=‘fristDb‘)
curs = conn.cursor()
curs.execute("drop table if exists fristTable")
sql = """create table fristTable (first_name char(20) not null,last_name char(20),age int,sex char(1))"""
curs.execute(sql)
conn.close()
#!/usr/bin/python
#coding=utf-8
import MySQLdb
conn = MySQLdb.connect(host=‘localhost‘,user=‘root‘,passwd=‘123‘,db=‘fristDb‘)
curs = conn.cursor()
sql = """insert into fristTable (first_name,last_name,age,sex) values (‘dragon‘,‘great‘,20,‘M‘)"""
try:
curs.execute(sql)
conn.commit()
except:
conn.rollback()
conn.close()
#encoding=utf-8
import sys
import MySQLdb
reload(sys)
sys.setdefaultencoding(‘utf-8‘)
db=MySQLdb.connect(user=‘root‘,charset=‘utf8‘)
标签:
原文地址:http://blog.csdn.net/yywan1314520/article/details/51044877