Spaces:
Sleeping
Sleeping
Download externals/databases/_pgdb.py from ByteRiot/CandidateExplorer: direct link, hf CLI and curl.
- Browser
- Download file 2.4 kB
-
https://huggingface.co/spaces/ByteRiot/CandidateExplorer/resolve/main/externals/databases/_pgdb.py
- Command line
-
hf download hf://spaces/ByteRiot/CandidateExplorer/externals/databases/_pgdb.py
-
curl -L -o _pgdb.py https://huggingface.co/spaces/ByteRiot/CandidateExplorer/resolve/main/externals/databases/_pgdb.py
2.4 kB
| # import os | |
| # import dotenv | |
| # dotenv.load_dotenv() | |
| # import asyncpg | |
| # # from datetime import datetime | |
| # async def fetch_data(query:str): | |
| # try: | |
| # conn = await asyncpg.connect(user=os.environ.get("causalogy--pg--user"), | |
| # password=os.environ.get("causalogy--pg--password"), | |
| # database=os.environ.get("causalogy--pg--name"), | |
| # host=os.environ.get("causalogy--pg--host"), | |
| # port=os.environ.get("causalogy--pg--port")) | |
| # values = await conn.fetch(query) | |
| # print(f"""β Fetching data succeeded!""") | |
| # return values | |
| # except Exception as E: | |
| # print(f"""β Error when Fetching data, {E}""") | |
| # finally: | |
| # await conn.close() | |
| # async def execute_query(query:str): | |
| # try: | |
| # conn = await asyncpg.connect(user=os.environ.get("causalogy--pg--user"), | |
| # password=os.environ.get("causalogy--pg--password"), | |
| # database=os.environ.get("causalogy--pg--name"), | |
| # host=os.environ.get("causalogy--pg--host"), | |
| # port=os.environ.get("causalogy--pg--port")) | |
| # values = await conn.execute(query) | |
| # print(f"""β Executing query succeeded!""") | |
| # return True | |
| # except Exception as E: | |
| # print(f"""β Error when Executing query, {E}""") | |
| # return False | |
| # finally: | |
| # await conn.close() | |
| # async def execute_insert_binary(filename: str, file_content: bytes, query:str="""INSERT INTO cv_raw (filename, file_content) VALUES ($1, $2);"""): | |
| # conn = None | |
| # try: | |
| # conn = await asyncpg.connect( | |
| # user=os.environ.get("causalogy--pg--user"), | |
| # password=os.environ.get("causalogy--pg--password"), | |
| # database=os.environ.get("causalogy--pg--name"), | |
| # host=os.environ.get("causalogy--pg--host"), | |
| # port=os.environ.get("causalogy--pg--port") | |
| # ) | |
| # await conn.execute(query, filename, file_content) | |
| # print(f"β Successfully inserted {filename} into cv_raw") | |
| # except Exception as E: | |
| # print(f"β Error when executing insert: {E}") | |
| # finally: | |
| # if conn: | |
| # await conn.close() |