· 8 years ago · Jul 02, 2018, 03:30 PM
1extern crate rusqlite;
2
3
4fn main()
5{
6 let mut threads = vec!();
7 for th in 0..300
8 {
9 let name = format!("{}.db", th);
10 let t = std::thread::spawn(
11 move ||
12 {
13 for _ in 0..100
14 {
15 let conn = rusqlite::Connection::open_with_flags(
16 &name,
17 rusqlite::OpenFlags::SQLITE_OPEN_NO_MUTEX
18 | rusqlite::OpenFlags::SQLITE_OPEN_READ_WRITE
19 | rusqlite::OpenFlags::SQLITE_OPEN_CREATE
20 ).expect(&format!("open sqlite db ({})", name));
21 conn.execute_batch(
22 "
23 PRAGMA journal_mode = WAL;
24 CREATE TABLE IF NOT EXISTS data (key primary key not null, data not null);
25 "
26 ).unwrap();
27 }
28 }
29 );
30 threads.push(t);
31 }
32
33 for th in threads
34 {
35 th.join();
36 }
37}