Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

27 Commits

Repository files navigation

ys-pgu

I will collect here different postgresql utilities which are helpful for me.

ys::pgu::query

A postgresql query builder utility.

Example

C++

#include<ys/pgu/query.h>
#include<iostream>intmain(int argc, char* argv[]) {
{
usingnamespaceys::pgu::query;auto q = select_from("users") &
where("city_id = $1") &
group_by("age") &
having(_("count(1)") > 10);
q.where() || (
_("city_id in ") &
_(
select_from("avail_cities") &
columns("id") &
(where("country_id") == 12)
)()
);
q.where()() && _("not blocked");
q & columns("age") &
order_by("name");
q & columns("count(1) as cnt");
std::cout << q.str() << std::endl;
}
return0;
}

SQL

-- Result:select age, count(1) as cnt from users
where
(city_id = $1or city_id in (select id from avail_cities where country_id =12))
and not blocked
group by age
havingcount(1) >10order by name

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages