Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
a9c5c98d
Commit
a9c5c98d
authored
Jan 28, 2015
by
Davis King
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added sqlite example. Needs comments
parent
7204ce1a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
0 deletions
+69
-0
CMakeLists.txt
examples/CMakeLists.txt
+4
-0
sqlite_ex.cpp
examples/sqlite_ex.cpp
+65
-0
No files found.
examples/CMakeLists.txt
View file @
a9c5c98d
...
...
@@ -111,4 +111,8 @@ if (OpenCV_FOUND)
endif
()
if
(
DLIB_LINK_WITH_SQLITE3
)
add_example
(
sqlite_ex
)
endif
()
examples/sqlite_ex.cpp
0 → 100644
View file @
a9c5c98d
// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
/*
*/
#include <iostream>
#include <dlib/sqlite.h>
#include <dlib/matrix.h>
using
namespace
dlib
;
using
namespace
std
;
// ----------------------------------------------------------------------------------------
bool
table_exists
(
database
&
db
,
const
std
::
string
&
tablename
)
{
return
query_int
(
db
,
"select count(*) from sqlite_master where name = '"
+
tablename
+
"'"
)
==
1
;
}
int
main
()
try
{
database
db
(
"stuff.db"
);
if
(
!
table_exists
(
db
,
"davis"
))
db
.
exec
(
"create table davis (name, age, data)"
);
statement
st
(
db
,
"insert into davis VALUES(?,?,?)"
);
string
name
=
"davis"
;
int
age
=
32
;
matrix
<
double
>
m
=
randm
(
3
,
3
);
st
.
bind
(
1
,
name
);
st
.
bind
(
2
,
age
);
st
.
bind
(
3
,
m
);
st
.
exec
();
statement
st2
(
db
,
"select * from davis"
);
st2
.
exec
();
while
(
st2
.
move_next
())
{
string
name
;
int
age
;
matrix
<
double
>
m
;
st2
.
get_column
(
0
,
name
);
st2
.
get_column
(
1
,
age
);
st2
.
get_column
(
2
,
m
);
cout
<<
name
<<
" "
<<
age
<<
"
\n
"
<<
m
<<
endl
<<
endl
;
}
}
catch
(
std
::
exception
&
e
)
{
cout
<<
e
.
what
()
<<
endl
;
}
// ----------------------------------------------------------------------------------------
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment