Skip to content

Commit

Permalink
sqlite test added
Browse files Browse the repository at this point in the history
  • Loading branch information
shankar2105 committed Mar 27, 2015
1 parent 57bb980 commit 6cf15b1
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.o
*.so
*.rlib
./*.lib

# Executables
*.exe
Expand All @@ -14,3 +15,7 @@

*/target/
/ciTest/*.lock

*/bin/
/sqlite_test/db
/sqlite_test/sqlite3.dll
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ install:
7z x -oC:\ mingw-w64-dgn-x86_64-20141001.7z;
}
- SET PATH=%PATH%;C:\mingw64\bin;
- cd sample_test/
- cd sqlite_test/
- ps: Start-FileDownload "https://www.sqlite.org/2015/sqlite-autoconf-3080803.tar.gz"
- cmd: 7z x sqlite-autoconf-3080803.tar.gz -o.\ && 7z x sqlite-autoconf-3080803.tar -o.\
- cd sqlite-autoconf-3080803 && sh --login && gcc -shared -o sqlite3.dll sqlite3.c -Wl,--output-def,sqlite3.def,--out-implib,libsqlite3.a && exit
Expand Down
1 change: 0 additions & 1 deletion sample_test
Submodule sample_test deleted from 073b90
20 changes: 20 additions & 0 deletions sqlite_test/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions sqlite_test/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]

name = "sqlite_test"
version = "0.0.1"
authors = ["Shankar2105 <[email protected]>"]

[dependencies.sqlite3]
git = "https://github.com/linuxfood/rustsqlite.git"
40 changes: 40 additions & 0 deletions sqlite_test/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
extern crate sqlite3;
pub use sqlite3::*;
//pub use sqlite3::cursor::*;
//use std::collections::hash::map::HashMap;
static STR: &'static str = "Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a
galley of type and scrambled it to make a type specimen book.";

fn prepare_vec_u8 (arr: &[u8]) -> Vec<u8> {
let mut vec = Vec::new();
for i in 0..arr.len() {
vec.push(arr[i]);
}
vec
}
fn main() {
// let str: String = "Maidsafe Sample Text".to_string();
let mut sql = sqlite3::open("./db").unwrap();
sql.exec("create table if not exists stud (blob varchar(255))").unwrap();
let mut query = sql.prepare("insert into stud(blob) values(?)", &None).unwrap();
query.bind_params(&[types::BindArg::Blob(prepare_vec_u8(&STR.as_bytes()))]);
query.step();
// sql.exec("insert into stud values('2', 'adam')").unwrap();
// sql.exec("insert into stud values('3', 'smith')").unwrap();
let mut result = sql.prepare("select * from stud", &None).unwrap();
// result.clear_bindings();
// let mut local: &str = "";
// let mut r = result.step_row().unwrap().unwrap();
// match r.get("blob").unwrap() {
// &types::BindArg::Integer(ref p) => println!("Data :: {:?}", p),
// _ => println!("Don't have Daniel's number."),
// }
loop {
println!("------------------------");
if result.step() == types::ResultCode::SQLITE_DONE{
break;
}
println!("Result :: {:?}", result.get_blob(0).unwrap());
}
}

0 comments on commit 6cf15b1

Please sign in to comment.