Skip to content

Commit 8a3d579

Browse files
committed
Add Comext reference database
1 parent 519b958 commit 8a3d579

6 files changed

Lines changed: 30 additions & 9 deletions

File tree

CHANGES.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
Release history
22
---------------
33

4+
0.3.0
5+
++++++++++++++++++
6+
7+
- Add Comext reference database (https://ec.europa.eu/eurostat/web/user-guides/data-browser/api-data-access/api-getting-started/comext-database).
8+
49
0.2.1
510
++++++++++++++++++
611

src/eurostat/eurostat.hpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,27 @@ struct Endpoint {
1212
std::string organization; // (aka agency)
1313
std::string description;
1414
std::string api_url;
15+
std::string source_id;
1516
};
1617

1718
//! API Endpoints
1819
static const std::unordered_map<std::string, Endpoint> ENDPOINTS = {
19-
{"ESTAT", {"EUROSTAT", "EUROSTAT database", "https://ec.europa.eu/eurostat/api/dissemination/sdmx/2.1/"}},
20+
{"COMEXT",
21+
{"COMEXT", "Comext reference database", "https://ec.europa.eu/eurostat/api/comext/dissemination/sdmx/2.1/",
22+
"ESTAT"}},
23+
{"ESTAT", {"EUROSTAT", "EUROSTAT database", "https://ec.europa.eu/eurostat/api/dissemination/sdmx/2.1/", "ESTAT"}},
2024
{"ECFIN",
2125
{"DG ECFIN", "Economic and Financial Affairs",
22-
"https://webgate.ec.europa.eu/ecfin/redisstat/api/dissemination/sdmx/2.1/"}},
26+
"https://webgate.ec.europa.eu/ecfin/redisstat/api/dissemination/sdmx/2.1/", "ECFIN"}},
2327
{"EMPL",
2428
{"DG EMPL", "Employment, Social Affairs and Inclusion",
25-
"https://webgate.ec.europa.eu/empl/redisstat/api/dissemination/sdmx/2.1/"}},
29+
"https://webgate.ec.europa.eu/empl/redisstat/api/dissemination/sdmx/2.1/", "EMPL"}},
2630
{"GROW",
2731
{"DG GROW", "Internal Market, Industry, Entrepreneurship and SMEs",
28-
"https://webgate.ec.europa.eu/grow/redisstat/api/dissemination/sdmx/2.1/"}},
32+
"https://webgate.ec.europa.eu/grow/redisstat/api/dissemination/sdmx/2.1/", "GROW"}},
2933
{"TAXUD",
3034
{"DG TAXUD", "Taxation and Customs Union",
31-
"https://webgate.ec.europa.eu/taxation_customs/redisstat/api/dissemination/sdmx/2.1/"}},
35+
"https://webgate.ec.europa.eu/taxation_customs/redisstat/api/dissemination/sdmx/2.1/", "TAXUD"}},
3236
};
3337

3438
/**

src/eurostat/eurostat_info_functions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ struct ES_Dataflows {
434434
const auto it = eurostat::ENDPOINTS.find(provider_id);
435435

436436
for (const auto &dataflow_id : dataflows) {
437-
string url = it->second.api_url + "dataflow/" + provider_id + "/" + dataflow_id +
437+
string url = it->second.api_url + "dataflow/" + it->second.source_id + "/" + dataflow_id +
438438
"?format=JSON&compressed=true&lang=" + language;
439439

440440
if (req_count == 0) {
@@ -703,7 +703,7 @@ struct ES_DataStructure {
703703
// Execute HTTP GET request
704704

705705
const auto it = eurostat::ENDPOINTS.find(provider_id);
706-
string url = it->second.api_url + "dataflow/" + provider_id + "/" + dataflow_id +
706+
string url = it->second.api_url + "dataflow/" + it->second.source_id + "/" + dataflow_id +
707707
"/latest?detail=referencepartial&references=descendants";
708708

709709
HttpSettings settings = HttpRequest::ExtractHttpSettings(context, url);
@@ -813,7 +813,7 @@ struct ES_DataStructure {
813813
// Execute HTTP GET request
814814

815815
const auto it = eurostat::ENDPOINTS.find(provider_id);
816-
string url = it->second.api_url + "contentconstraint/" + provider_id + "/" + dataflow_id;
816+
string url = it->second.api_url + "contentconstraint/" + it->second.source_id + "/" + dataflow_id;
817817

818818
HttpSettings settings = HttpRequest::ExtractHttpSettings(context, url);
819819
auto response = HttpRequest::ExecuteHttpRequest(settings, url, "GET", HttpHeaders(), "", "");

test/sql/eurostat.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ require eurostat
1515
query I
1616
SELECT count(*) FROM EUROSTAT_Endpoints()
1717
----
18-
5
18+
6

test/sql/eurostat_endpoints.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ ORDER BY
1414
provider_id
1515
;
1616
----
17+
COMEXT https://ec.europa.eu/eurostat/api/comext/dissemination/sdmx/2.1/
1718
ECFIN https://webgate.ec.europa.eu/ecfin/redisstat/api/dissemination/sdmx/2.1/
1819
EMPL https://webgate.ec.europa.eu/empl/redisstat/api/dissemination/sdmx/2.1/
1920
ESTAT https://ec.europa.eu/eurostat/api/dissemination/sdmx/2.1/

test/sql/eurostat_read.test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,14 @@ ES 2003 F
4242
PT 2001 F
4343
PT 2002 F
4444
PT 2003 F
45+
46+
query III
47+
SELECT
48+
time_period, product, reporter
49+
FROM
50+
EUROSTAT_Read('COMEXT', 'DS-059341') WHERE time_period = '2006-05' AND product = '0103' AND reporter = 'FR'
51+
LIMIT 2
52+
;
53+
----
54+
2006-05 0103 FR
55+
2006-05 0103 FR

0 commit comments

Comments
 (0)