久久国产成人av_抖音国产毛片_a片网站免费观看_A片无码播放手机在线观看,色五月在线观看,亚洲精品m在线观看,女人自慰的免费网址,悠悠在线观看精品视频,一级日本片免费的,亚洲精品久,国产精品成人久久久久久久

分享

sqlite3 數(shù)據(jù)庫操作指令

 減熵君 2021-03-29

導(dǎo)入數(shù)據(jù)庫

import sqlit3

連接數(shù)據(jù)庫

conn = sqlite3.connent("test.db")

創(chuàng)建游標(biāo)

cursor = connn.cursor()

創(chuàng)建表

sql = "create table login(id varchar(20) primary key, name varchar(30), password varchar(30))"

cursor.execute(sql)

常用增刪改查

# 查看表結(jié)構(gòu)cur.execute("PRAGMA table_info(jobs)")

# 表中增加字段cur.execute("alter table WeakManager add release_time text")

# 重命名表alter table tema rename to team2;

# 刪除表中字段password(不支持刪除列)alter table wx_userInfo drop column password;

# 刪除表cur.execute("drop table WeakManager")
# 刪除數(shù)據(jù)delete from wx_userInfo where id=3;

# 添加數(shù)據(jù)insert into table_name(v1, v2) values (v1, v2);

cur.execute("insert into people values (?, ?)", (who, age))

cur.execute("select * from people where name=:who and age=:age",{"who": who, "age": age})

-- 修改數(shù)據(jù)update wx_userInfo set name='bbb',nickName='bbb' where openID='xxxxxx';

-- 在原有數(shù)據(jù)上增加數(shù)據(jù)update wx_userInfo set control_order=control_order||'on_off=0' where _id=40;

-- 查詢所以數(shù)據(jù)select * from wx_userInfo;-- 查詢指定數(shù)量條數(shù)select * from wx_userInfo limit 3;

-- 查詢升序輸出記錄select * from wx_userInfo order by id asc;

-- 查詢降序輸出記錄select * from wx_userInfo order by id desc;

-- 條件查詢select * from wx_userInfo where id in('3');select * from wx_userInfo where id between 0 and 2;

-- 查詢指定字段記錄數(shù)量統(tǒng)計(jì)select count(nickName) from wx_userInfo;select count(unionID) from wx_userInfo;

-- 查詢指定字段的數(shù)據(jù)(將指定字段可能重復(fù)的數(shù)據(jù)去掉,列出所有不同的數(shù)據(jù))select distinct unionID from wx_userInfo;select distinct id from wx_userInfo;

-- 查詢最后一條數(shù)據(jù),,order by id desc 倒序,然后查找最后一條 
limit 0,1select id, room_id,control_order,date_time from control_table order by id desc limit 0,1;

結(jié)束操作

# 1.提交事務(wù)conn.commit()# 2.關(guān)閉游標(biāo)cursor.close()# 3.關(guān)閉連接conn.close()

    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,,所有內(nèi)容均由用戶發(fā)布,,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式,、誘導(dǎo)購買等信息,,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,,請(qǐng)點(diǎn)擊一鍵舉報(bào),。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多