Adding OData Import
This commit is contained in:
1 parent
c8696e67b5
commit
291416544e
18 files changed
+547
-3
No files matched your search
@@ -0,0 +1,34 @@
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.models.imported_part_config import ImportedPartConfig
|
||||
|
||||
_SINGLETON_ID = 1
|
||||
|
||||
|
||||
async def get(db: AsyncSession) -> ImportedPartConfig | None:
|
||||
return await db.get(ImportedPartConfig, _SINGLETON_ID)
|
||||
|
||||
|
||||
async def upsert(
|
||||
db: AsyncSession,
|
||||
*,
|
||||
odata_url: str | None,
|
||||
username: str | None,
|
||||
password: str | None,
|
||||
) -> ImportedPartConfig:
|
||||
config = await db.get(ImportedPartConfig, _SINGLETON_ID)
|
||||
if config is None:
|
||||
config = ImportedPartConfig(
|
||||
id=_SINGLETON_ID,
|
||||
odata_url=odata_url,
|
||||
username=username,
|
||||
password=password,
|
||||
)
|
||||
db.add(config)
|
||||
else:
|
||||
config.odata_url = odata_url
|
||||
config.username = username
|
||||
config.password = password
|
||||
await db.commit()
|
||||
await db.refresh(config)
|
||||
return config
|
||||
Reference in new issue
Block a user