Datasets:
Download evals/schema-first/heldout/sql-remote-graph-no-schema-source/files/reports/run.py from erdostack/bench: direct link, hf CLI and curl.
- Browser
- Download file 626 Bytes
-
https://huggingface.co/datasets/erdostack/bench/resolve/main/evals/schema-first/heldout/sql-remote-graph-no-schema-source/files/reports/run.py
- Command line
-
hf download hf://datasets/erdostack/bench/evals/schema-first/heldout/sql-remote-graph-no-schema-source/files/reports/run.py
-
curl -L -o run.py https://huggingface.co/datasets/erdostack/bench/resolve/main/evals/schema-first/heldout/sql-remote-graph-no-schema-source/files/reports/run.py
626 Bytes
| """Run one SQL file against the read replica and print CSV.""" | |
| import csv | |
| import os | |
| import sys | |
| from pathlib import Path | |
| def main(path): | |
| import psycopg # imported here so the module can be loaded without the driver | |
| with psycopg.connect(os.environ["DATABASE_URL"], autocommit=True) as conn: | |
| conn.execute("SET default_transaction_read_only = on") | |
| cur = conn.execute(Path(path).read_text(encoding="utf-8")) | |
| writer = csv.writer(sys.stdout) | |
| writer.writerow([col.name for col in cur.description]) | |
| writer.writerows(cur.fetchall()) | |
| if __name__ == "__main__": | |
| main(sys.argv[1]) | |