国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
python模塊之MySQLdb: 用python連接mysql數(shù)據(jù)庫
mysql是一個優(yōu)秀的開源數(shù)據(jù)庫,它現(xiàn)在的應(yīng)用非常的廣泛,因此很有必要簡單的介紹一下用python操作mysql數(shù)據(jù)庫的方法。python操作數(shù)據(jù)庫需要安裝一個第三方的模塊,在http://mysql-python.sourceforge.net/
有下載和文檔。
    由于python的數(shù)據(jù)庫模塊有專門的數(shù)據(jù)庫模塊的規(guī)范,所以,其實不管使用哪種數(shù)據(jù)庫的方法都大同小異的,這里就給出一段示范的代碼:
#-*- encoding: gb2312 -*-
import
 os, sys, string
import
 MySQLdb
# 連接數(shù)據(jù)庫 
try:
    conn = MySQLdb.connect(host='localhost',user='root',passwd='xxxx',db='test1')
except Exception, e:    
    print e
    sys.exit()
# 獲取cursor對象來進行操作
cursor = conn.cursor()
# 創(chuàng)建表
sql ="create table if not exists test1(name varchar(128) primary key, age int(4))"
cursor.execute(sql)
# 插入數(shù)據(jù)
sql = "insert into test1(name, age) values ('%s', %d)"% ("zhaowei", 23)
try:
    cursor.execute(sql)
except Exception, e:
    print e
sql ="insert into test1(name, age) values ('%s', %d)"% ("張三", 21)
try:
    cursor.execute(sql)
except Exception, e:   
    print e
# 插入多條
sql ="insert into test1(name, age) values (%s, %s)"val = (("李四", 24), ("王五", 25), ("洪六", 26))
try:
    cursor.ex ......
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Python操作mysql數(shù)據(jù)庫:MySQLdb模塊
[Python]MySQLdb for Python使用指南/Python的數(shù)據(jù)庫操作
python操作mysql數(shù)據(jù)庫 | 菜鳥教程
Python操作Mysql - 課程 - 從此學(xué)習(xí)網(wǎng)
Python使用MySQL數(shù)據(jù)庫的方法以及一個實例
Python MySQL
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服