SQLite Cheatsheet
目录
types
- text -> str
- int -> int
- timestamp
where stmt
where <col1> <op1> <value1> <logic op1> <col2> <op2> <value2> ...
initialization
python / sqlite3
conn = sqlite3.connect(<db path>, detect_types=sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES)
conn.row_factory = sqlite3.Row
notice: sqlite objects can't be used across different threads
create table
create table [if not exists] <name> (<col1 name> <col1 type>, <col2 name> <col2 type>, ...)
drop table
drop table [if exists] <name>
insert
insert into <table name> values (?, ?, ...)
delete
delete from <table name> where <where stmt>
update
update <table name> set <col1 name>=?, <col2 name>=?, ... where <where stmt>
query
select <cols> from <table name> [where <where stmt>] [order by <order col>] [offset <skip count>] [limit <result limit>]