FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
constexpr-sql/example.cpp at master · mkitzan/constexpr-sql · GitHub
mkitzan
/
constexpr-sql
Public
Notifications
You must be signed in to change notification settings
Fork
7
Star
142
Code
Issues
2
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
constexpr-sql
/
example.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
41 lines (34 loc) · 973 Bytes
Breadcrumbs
constexpr-sql
/
example.cpp
Copy path
File metadata and controls
41 lines (34 loc) · 973 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#
include
<
iostream
>
#
include
<
string
>
#
include
"
sql.hpp
"
using
books =
sql::schema<
"
books
"
, sql::index<
"
title
"
>,
sql::column<
"
title
"
, std::string>,
sql::column<
"
genre
"
, std::string>,
sql::column<
"
year
"
,
unsigned
>,
sql::column<
"
pages
"
,
unsigned
>
>;
using
authored =
sql::schema<
"
authored
"
, sql::index<>,
sql::column<
"
title
"
, std::string>,
sql::column<
"
name
"
, std::string>
>;
using
query =
sql::query<
"
SELECT title AS book, name AS author, year, pages
"
"
FROM books NATURAL JOIN (SELECT * FROM authored WHERE name =
\"
Harlan Ellison
\"
)
"
"
WHERE year = 1967 OR year >= 1972 AND genre =
\"
science fiction
\"
"
,
books, authored
>;
int
main
()
{
authored a{ sql::load<authored>(
"
tests/data/authored.tsv
"
,
'
\t
'
) };
books b{ sql::load<books>(
"
tests/data/books.tsv
"
,
'
\t
'
) };
for
(query q{ b, a };
auto
const
& [book, author, year, pages] : q)
{
std::cout << book <<
'
\t
'
<< author <<
'
\t
'
<< year <<
'
\t
'
<< pages <<
'
\n
'
;
}
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL