参考地址:https://blog.csdn.net/guangdeshishe/article/details/125295529
单条:
sqlite3 ../rule_pcap_80t.db <<EOF >${name}_ignore_key
select ignore_keys from pcap_es_and_ignore_key where pcap_name="${name}" and suuid="S3100109841";
EOF
参考地址:https://blog.csdn.net/guangdeshishe/article/details/125295529
单条:
sqlite3 ../rule_pcap_80t.db <<EOF >${name}_ignore_key
select ignore_keys from pcap_es_and_ignore_key where pcap_name="${name}" and suuid="S3100109841";
EOF
https://www.mobibrw.com/2021/30117
注意:
1 2 3 4 | sqlite3只支持一写多读. 读与读可以同时进行 读与写不可同时进行 写与写不可同时进行 |
什么时候会返回SQLITE_BUSY错误码?
官方文档给出的解释是:
1 2 | The SQLITE_BUSY result code indicates that the database file could not be written (or in some cases read) because of concurrent activity by some other database connection, usually a database connection in a separate process. |
SQLite只支持库级锁,库级锁意味着什么?——意味着同时只能允许一个写操作,也就是说,即事务T1在A表插入一条数据,事务T2在B表中插入一条数据,这两个操作不能同时进行,即使你的机器有100个CPU,也无法同时进行,而只能顺序进行。表级都不能并行,更别说元组级了——这就是库级锁。但是,SQLite尽量延迟申请X锁,直到数据块真正写盘时才申请X锁,这是非常巧妙而有效的。
简单的办法,全局加锁,单线程执行,复杂一点,则可以启用一个专门的数据库线程异步执行操作。
https://www.jianshu.com/p/2980342c7be6
2. .mode insert
设置输出模式,MODE 可以是下列之一:
csv 逗号分隔的值
column 左对齐的列
html HTML 的 <table> 代码
insert TABLE 表的 SQL 插入(insert)语句
line 每行一个值
list 由 .separator 字符串分隔的值
tabs 由 Tab 分隔的值
tcl TCL 列表元素
3. .output 文件名
例: .output city.sql
4. .dump 表名
例:.dump t_city
5. .quit 退出
sqlite3 -csv -header vz3.db "select * from t_city_domestic_all_new" > city.csv
来源:https://www.sqlite.net.cn/cli.html
在交互模式下,sqlite3从键盘读取输入文本(SQL语句或点命令)。当然,当您启动sqlite3时,也可以从文件重定向输入,但是这样您就无法与该程序进行交互。有时,运行包含在文件中的SQL脚本很有用,该脚本从命令行输入其他命令。为此,提供了“ .read”点命令。
“ .read”命令采用单个参数,该参数通常是从中读取输入文本的文件的名称。
sqlite> .read myscript.sql
“ .read”命令暂时停止从键盘读取,而是从命名文件中获取其输入。到达文件末尾时,输入将返回到键盘。脚本文件可能包含点命令,就像普通的交互式输入一样。
c = conn.cursor() # Create table c.execute('''CREATE TABLE stocks (date text, trans text, symbol text, qty real, price real)''') # Insert a row of data c.execute("INSERT INTO stocks VALUES ('2006-01-05','BUY','RHAT',100,35.14)") # Save (commit) the changes conn.commit() # We can also close the connection if we are done with it. # Just be sure any changes have been committed or they will be lost. conn.close()
--------------------------
[popexizhi]
问题: c.execute(creat_sql) Warning: You can only execute one statement at a time
解决:http://stackoverflow.com/questions/15513854/sqlite3-warning-you-can-only-execute-one-statement-at-a-time
From Python sqlite3 docs:
"execute() will only execute a single SQL statement. If you try to execute more than one statement with it, it will raise a Warning. Use executescript() if you want to execute multiple SQL statements with one call."