中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

建網(wǎng)站公司成都百度服務(wù)中心投訴

建網(wǎng)站公司成都,百度服務(wù)中心投訴,吉隆坡建設(shè)大學(xué)中文網(wǎng)站,邢臺論壇提示:文章寫完后,目錄可以自動生成,如何生成可參考右邊的幫助文檔 文章目錄 一、MYSQL二、MySQL管理查看已有數(shù)據(jù)庫創(chuàng)建數(shù)據(jù)庫刪除數(shù)據(jù)庫進(jìn)入數(shù)據(jù)庫創(chuàng)建表刪除表展示表的行列插入數(shù)據(jù)查看表中的數(shù)據(jù)刪除數(shù)據(jù)修改數(shù)據(jù) 三、python代碼執(zhí)行數(shù)據(jù)庫…

提示:文章寫完后,目錄可以自動生成,如何生成可參考右邊的幫助文檔

文章目錄

  • 一、MYSQL
  • 二、MySQL管理
    • 查看已有數(shù)據(jù)庫
    • 創(chuàng)建數(shù)據(jù)庫
    • 刪除數(shù)據(jù)庫
    • 進(jìn)入數(shù)據(jù)庫
    • 創(chuàng)建表
    • 刪除表
    • 展示表的行列
    • 插入數(shù)據(jù)
    • 查看表中的數(shù)據(jù)
    • 刪除數(shù)據(jù)
    • 修改數(shù)據(jù)
  • 三、python代碼執(zhí)行數(shù)據(jù)庫操作
    • 動態(tài)創(chuàng)建
    • 查詢數(shù)據(jù)
    • 刪除數(shù)據(jù)
    • 修改數(shù)據(jù)


一、MYSQL

數(shù)據(jù)庫相當(dāng)于我們常用的文件夾,數(shù)據(jù)表相當(dāng)于我們常用說的文件,文件夾中存放文件,即數(shù)據(jù)庫中存放數(shù)據(jù)表。當(dāng)要創(chuàng)建一個新表時,需要選定某個數(shù)據(jù)庫才能進(jìn)行創(chuàng)建。

二、MySQL管理

查看已有數(shù)據(jù)庫

show databases;  

在這里插入圖片描述

創(chuàng)建數(shù)據(jù)庫

create database 數(shù)據(jù)庫名字 DEFAULT CHARSET utf8 COLLATE utf8_general_ci ;

create database demo2 DEFAULT CHARSET utf8 COLLATE utf8_general_ci ;

在這里插入圖片描述

刪除數(shù)據(jù)庫

drop database 數(shù)據(jù)庫名字;

 drop database demo2;

在這里插入圖片描述

進(jìn)入數(shù)據(jù)庫

use 數(shù)據(jù)庫名字;

 use demo1;

在這里插入圖片描述
注意:查看數(shù)據(jù)表(show tables;);創(chuàng)建數(shù)據(jù)表(create table 數(shù)據(jù)表名),需要先進(jìn)入文件夾再查看,即use 連接使用。

創(chuàng)建表

create table tb11(
-> id int primary key, //主鍵 不能為空,表示唯一標(biāo)識
-> name varchar(16) not null, //不能為空,(16不能少)
-> age int null //可以為空 (最后一項不能有”,“)
-> )default charset=utf8;

create table tb11(
id int primary key, 
name varchar(16) not null,
age int null
)default charset=utf8;

注意: -> id int auto_increment primary key, //自增 1 2… √
在這里插入圖片描述

刪除表

drop table 表名稱;

 drop table tb2;

在這里插入圖片描述

展示表的行列

desc 表名稱;

desc tb1;

在這里插入圖片描述

插入數(shù)據(jù)

insert into 表名字(name,age) values(“嬋嬋”,22),(“ww”,19);

insert into tb1(id,name,age) values(1,"aa",20),(2,"bb",21);

在這里插入圖片描述

查看表中的數(shù)據(jù)

select * from 表名字;

select * from tb1;

在這里插入圖片描述

刪除數(shù)據(jù)

delete from 表名字;
delete from 表名字 where 條件 ;
eg: delete from tb33 where id = 1;
delete from tb33 where id = 1 and name=”aa”;
delete from tb33 where id <=4;

delete from tb1 where id=1;

在這里插入圖片描述

修改數(shù)據(jù)

update 表名字set 列=值;
update 表名字set 列=值,列=值;
update 表名字set age=age+10 where 條件;

update tb1 set name="cc";

在這里插入圖片描述

三、python代碼執(zhí)行數(shù)據(jù)庫操作

打開pycharm --創(chuàng)建新項目–終端寫入pip(版本號) install pymysql

動態(tài)創(chuàng)建

(注意縮進(jìn))

import pymysql
while True:username=input("用戶名:")if username.upper()=='Q':breakpassword=input("密碼:")mobile=input("手機(jī)號:")
# 1.連接MySQLconn=pymysql.connect(host="127.0.0.1",port=3306,user='root',passwd="12345",charset='utf8',db='unicom')cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)
# 2.發(fā)送指令  (不能用字符串格式化去做MySQL的拼接,有安全隱患)sql="insert into admin(username,password,mobile) values(%s,%s,%s)"cursor.execute(sql,[username,password,mobile])conn.commit()
# 3.關(guān)閉cursor.close()conn.close()

其中passwd="12345"表示進(jìn)入數(shù)據(jù)庫的密碼,db='unicom’是新建的數(shù)據(jù)庫名字,admin是新建表的名字,均可自行設(shè)置。

在這里插入圖片描述
在這里插入圖片描述

查詢數(shù)據(jù)

全部數(shù)據(jù): fetchall() 無數(shù)據(jù)為空列表
符合條件的第一個數(shù)據(jù): fetchone() 無數(shù)據(jù)是none

import pymysql
# 1.連接MySQL
conn=pymysql.connect(host="127.0.0.1",port=3306,user='root',passwd="12345",charset='utf8',db='unicom')
cursor = conn.cursor(cursor=pymysql.cursors.DictCursor)# 2.執(zhí)行查詢的指令
cursor.execute("select * from  admin ",)
# %s是exceute的占位符,
rew=cursor.fetchone()
# print(data_list)
# 得出的結(jié)果是以字典形式展示列表中的數(shù)據(jù)
print(rew)
# 3.關(guān)閉
cursor.close()
conn.close()

在這里插入圖片描述

刪除數(shù)據(jù)

cursor.execute("delete from admin where id =%s",[8,])

8后面的逗號不能省略掉。

修改數(shù)據(jù)

cursor.execute("update admin set mobile=%s where id =%s",["49999999999",7,])

7后面的逗號不能省略掉。

http://www.risenshineclean.com/news/42857.html

相關(guān)文章:

  • 網(wǎng)站怎么做友情鏈接深圳關(guān)鍵詞排名推廣
  • 做網(wǎng)站簡單嗎百度后臺管理
  • 安徽省建設(shè)廳網(wǎng)站證書查詢跨境網(wǎng)站建站
  • 做商城網(wǎng)站要什么手續(xù)百度公司簡介
  • 趣聞網(wǎng)站如何做建設(shè)網(wǎng)站流程
  • 網(wǎng)站背景怎么設(shè)置seo教學(xué)視頻教程
  • 如何制作和設(shè)計公司網(wǎng)站seo關(guān)鍵詞排名教程
  • 晉江網(wǎng)站有什么職業(yè)做百度網(wǎng)站站長工具
  • 系統(tǒng)開發(fā)費(fèi)用seo模擬點(diǎn)擊算法
  • 淘寶做網(wǎng)站費(fèi)用5118營銷大數(shù)據(jù)
  • 網(wǎng)站開發(fā)與移動互聯(lián)seo和競價排名的區(qū)別
  • 有做喜糖的網(wǎng)站嗎網(wǎng)絡(luò)工程師
  • 購物網(wǎng)站難做嗎網(wǎng)站優(yōu)化關(guān)鍵詞價格
  • 微信公眾號排版appseo的收費(fèi)標(biāo)準(zhǔn)
  • 做網(wǎng)站基本費(fèi)用大概需要多少sem專員
  • 做app和網(wǎng)站哪個比較好用免費(fèi)推廣有哪些
  • 怎么做網(wǎng)站編程web網(wǎng)頁
  • 手機(jī)應(yīng)用軟件開發(fā)seo在線教程
  • 鞋店網(wǎng)站建設(shè)方案石家莊市人民政府官網(wǎng)
  • 淘寶客網(wǎng)站怎么備案新手小白怎么學(xué)做運(yùn)營
  • 企業(yè)網(wǎng)站如何做seo全國十大跨境電商公司排名
  • 做視頻點(diǎn)播網(wǎng)站要多少帶寬今日重慶重要消息
  • 58這種網(wǎng)站怎么做nba實(shí)力榜最新排名
  • 虎門專業(yè)網(wǎng)站建設(shè)seo群發(fā)軟件
  • 保定中小企業(yè)網(wǎng)站制作推廣普通話內(nèi)容50字
  • 網(wǎng)站的注冊和登錄怎么做友情鏈接聯(lián)盟
  • 開源快速網(wǎng)站搭建平臺磁力寶最佳搜索引擎入口
  • wordpress社團(tuán)網(wǎng)站今日頭條最新
  • 視頻網(wǎng)站外鏈怎么做搜什么關(guān)鍵詞比較刺激
  • 西部數(shù)碼網(wǎng)站管理助手4.0 破解版鏈接交易網(wǎng)