(以“== types == * text -> str * int -> int * timestamp == where stmt == <pre>where <col1> <op1> <value1> <logic op1> <col2> <op2> <value2> ...</pre> == initialization ...”为内容创建页面)
 
 
第28行: 第28行:
  
 
== update ==
 
== update ==
<pre>update <table name> set <col1 name>=?, <col2 name>=?, ...</pre>
+
<pre>update <table name> set <col1 name>=?, <col2 name>=?, ... where <where stmt></pre>
  
 
== query ==
 
== query ==
 
<pre>select <cols> from <table name> [where <where stmt>] [order by <order col>] [offset <skip count>] [limit <result limit>]</pre>
 
<pre>select <cols> from <table name> [where <where stmt>] [order by <order col>] [offset <skip count>] [limit <result limit>]</pre>

2014年8月6日 (三) 18:40的最新版本

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>]