sqlite3的基本使用

2021-04-26 03:29:35 字數 570 閱讀 6013

在linux下使用sqlite資料庫

2.其次在當前目錄中建立資料庫,使用如下命令:

$ sqlite3 test.db

3.進入資料庫後,在提示符(sqlite>)輸入如下命令:

sqlite> .databases

此時,到當前目錄下,可以看到test.db生成

這樣,資料庫建立完成

4.在test.db資料庫中的基本操作如下:

sqlite> create table users(

...>   name varchar(30),

...>   age smallint,

...>   gender varchar(2)

...> );

sqlite> select * from users;

sqlite> insert into users(name, age, gender) values('aaa', 23, '男');

sqlite> select * from users;

5.sqlite的基本命令:

.help 幫助

.exit 退出資料庫

使用sqlite3 模組操作sqlite3資料庫

python內建了sqlite3模組,可以操作流行的嵌入式資料庫sqlite3。如果看了我前面的使用 pymysql 操作mysql資料庫這篇文章就更簡單了。因為它們都遵循pep 249,所以操作方法幾乎相同。廢話就不多說了,直接看 吧。都差不多,首先匯入模組,然後建立連線,然後獲取游標物件,之後利...

SQlite3基本用法,使用sublime編輯器

coding utf 8 import sqlite3 1.連線資料庫,檔案不存在自動建立新的資料庫檔案 connect sqlite3.connect database.db 2.連線游標 cursor connect.cursor 3.向資料庫database.db新增一張表,以及四個欄位id,...

sqlite3基本操作

sqlite3對很多通過的sql語句都支援,像select,update,insert,delete等等都支援地很好,只要懂sql語句就可以用sqlite3。1,下面是幾個比較重要的api函式 開啟資料庫,如果不存在則建立乙個 int sqlite3 open const char sqlite3 ...