Thanks for using Compiler Explorer
SQL
ByePy
byepy source #1
Output
Compile to binary
Execute the code
Intel asm syntax
Demangle identifiers
Filters
Unused labels
Library functions
Directives
Comments
Horizontal whitespace
Compiler
/usr/local/bin/ByePy-exe
Options
Source code
""" ByePy - Simple Example Copyright (C) 2022 Tim Fischer default.py This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. """ from dataclasses import dataclass import os from dotenv import load_dotenv from byepy import connect, DEFINE, register_composite, to_compile, SQL load_dotenv() connect(os.getenv("AUTH_STR")) DEFINE( """ DROP TABLE IF EXISTS thing; CREATE TABLE thing ( name text , age int4 ); """ ) @register_composite @dataclass class Thing: name: str age: int @to_compile def name_of_youngest_thing_older_than(threshold: int) -> str: things_older_than: list[Thing] = SQL( """SELECT array_agg(thing) FROM thing WHERE age > $1 """, [threshold] ) youngest_thing: Thing = things_older_than[0] for thing in things_older_than[1:]: if thing.age < youngest_thing.age: youngest_thing = thing return youngest_thing.name
Become a Patron
Sponsor on GitHub
Donate via PayPal
Source on GitHub
Mailing list
Installed libraries
Wiki
Report an issue
How it works
Contact the author
About the author
Changelog
Version tree