Python8 資料庫基礎

2022-09-10 02:03:13 字數 1637 閱讀 2084

python爬蟲

適用場景

考慮到事務和日誌

非關係型資料庫(nosql, not noly sql)

建立在nosql系統儲存(鍵對值)基礎上的資料庫, 既可以儲存結構化的資料, 也可以儲存非結構化的資料.

資料庫分為服務端和客戶端

資料庫(database)

retrieve

show databases;
update

alter database tunan_class_2 default character set 'utf8mb4'
delete

drop database 庫名
資料表(table)

比較運算子

邏輯運算子

字元處理

> 建立表的時候盡量加上create_time欄位, 為create_time設定預設值current_timestamp

retrieve(查)

獲取查詢結果的條數(count)

select count(*) from 表名 [條件語句]
update(更新)

update 表名 set 欄位1=新值, 欄位2=新值 where 表示式

update class_1 set name='name_0' where id=8

delete(刪除)

delete from 表名 where 表示式

補集

a與b的補集 = a與b的並集 - a與b的交集

a與b的補集 = a對b的差集 + b對a的差集 √

select s1.name from

(select name from class_1 where name is not null) as s1

left join

(select name from class_2 where name is not null) as s2

on s1.name=s2.name

where s2.name is null

union

select s2.name from

(select name from class_1 where name is not null) as s1

right join

(select name from class_2 where name is not null) as s2

on s1.name=s2.name

where s1.name is null

python 8 資料結構

容器 序列 列表元組 對映 字典 集合在python中 沒有陣列 用系列資料型別代替陣列 系列資料型別 系列資料型別 python中最簡單的資料結構 可以包含乙個或者多個元素 這裡的多個元素的資料型別可以是不一致的 所以python裡面沒有陣列 也可以包含空集合 包含列表 元組 字串 位元組資料序列...

python(8)異常處理

所有異常物件都是exception的成員。常見異常類 nameerror 變數未宣告 zerodivisionerror 除零異常 synatacerror 語法錯誤 indexerror 索引不存在 keyerror 鍵不存在 filenotfounderror 檔案不存在 attributeer...

菜鳥學python 8 初識函式

想寫點東西把自己學習python的過程記錄下來,於是就有了菜鳥學python def是python中函式的關鍵字,fun是命名的函式名,中是函式引數 先寫乙個簡單的將兩個字元相 加 def fun1 x return x x 函式寫好了,可以用下面的方法實現它 x raw input please ...