· 8 years ago · Jul 02, 2018, 04:44 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 CREATE TABLE IF NOT EXISTS data (key primary key not null, data not null);
24 "
25 ).unwrap();
26 }
27 }
28 );
29 threads.push(t);
30 }
31
32 for th in threads
33 {
34 th.join();
35 }
36}