-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from airtai/first-sheet-endpoint
First sheet endpoint
- Loading branch information
Showing
7 changed files
with
330 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,5 @@ venv* | |
htmlcov | ||
token | ||
.DS_Store | ||
|
||
client_secret*.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from contextlib import asynccontextmanager | ||
from os import environ | ||
from typing import AsyncGenerator, Optional | ||
|
||
from prisma import Prisma # type: ignore[attr-defined] | ||
|
||
|
||
@asynccontextmanager | ||
async def get_db_connection( | ||
db_url: Optional[str] = None, | ||
) -> AsyncGenerator[Prisma, None]: | ||
if not db_url: | ||
db_url = environ.get("DATABASE_URL", None) | ||
if not db_url: | ||
raise ValueError( | ||
"No database URL provided nor set as environment variable 'DATABASE_URL'" | ||
) # pragma: no cover | ||
if "connect_timeout" not in db_url: | ||
db_url += "?connect_timeout=60" | ||
db = Prisma(datasource={"url": db_url}) | ||
await db.connect() | ||
try: | ||
yield db | ||
finally: | ||
await db.disconnect() | ||
|
||
|
||
async def get_wasp_db_url() -> str: | ||
curr_db_url = environ.get("DATABASE_URL") | ||
wasp_db_name = environ.get("WASP_DB_NAME", "waspdb") | ||
wasp_db_url = curr_db_url.replace(curr_db_url.split("/")[-1], wasp_db_name) # type: ignore[union-attr] | ||
if "connect_timeout" not in wasp_db_url: | ||
wasp_db_url += "?connect_timeout=60" | ||
return wasp_db_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
datasource db { | ||
// could be postgresql or mysql | ||
provider = "postgresql" | ||
url = env("DATABASE_URL") | ||
} | ||
|
||
generator db { | ||
provider = "prisma-client-py" | ||
interface = "asyncio" | ||
recursive_type_depth = 5 | ||
} | ||
|
||
model GAuth { | ||
id String @id @default(cuid()) | ||
created_at DateTime @default(now()) | ||
updated_at DateTime @updatedAt | ||
user_id Int @unique | ||
creds Json | ||
info Json | ||
} |
Oops, something went wrong.