blob: 1e6c3cc8cc1824f916b8c05e4ed82616087261e6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#!/usr/bin/python
import asyncio
import glob
import os
import asyncpg
queries = dict()
async def load_queries(path):
"""Prepares a folder of SQL files as SQL statements.
:param path: Path to the `.sql` files.
:type path: str
"""
# load from queries/
queryfiles = glob.glob(path + "/*.sql")
for fp in queryfiles:
with open(fp, "r", encoding="utf-8-sig") as qfile:
name = os.path.splitext(os.path.basename(fp))[0]
queries[name] = qfile.read()
|