Here are the examples of the python api sqlalchemy.select.where taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
683 Examples
3
Source : sqlalchemy.py
with MIT License
from alex-oleshkevich
with MIT License
from alex-oleshkevich
async def _fetch_user_by_column(self, column: str, value: typing.Any) -> typing.Optional[UserLike]:
column = getattr(self._identity_table.c, column)
stmt = select(self._identity_table).where(column == value)
async with self._engine.begin() as connection: # type: AsyncConnection
result: Result = await connection.execute(stmt)
row = result.one_or_none()
if row:
return self._user_model(**dict(row))
return None
class SQLAlchemyORMUserProvider(UserProvider):
3
Source : sqlalchemy.py
with MIT License
from alex-oleshkevich
with MIT License
from alex-oleshkevich
async def _fetch_user_by_column(self, column: str, value: typing.Any) -> typing.Optional[UserLike]:
column = getattr(self._user_model, column)
stmt = select(self._user_model).where(column == value)
async with self._session_maker() as session: # type: AsyncSession
result: Result = await session.execute(stmt)
return result.scalar_one_or_none()
3
Source : models.py
with BSD 3-Clause "New" or "Revised" License
from aminalaee
with BSD 3-Clause "New" or "Revised" License
from aminalaee
def _update_modeL_sync(self, pk: Any, data: Dict[str, Any]) -> None:
stmt = select(self.model).where(
self.pk_column == self._get_column_python_type(self.pk_column)(pk)
)
relationships = inspect(self.model).relationships
with self.sessionmaker.begin() as session:
result = session.execute(stmt).scalars().first()
for name, value in data.items():
if name in relationships and isinstance(value, list):
# Load relationship objects into session
session.add_all(value)
setattr(result, name, value)
def _get_column_python_type(self, column: Column) -> type:
3
Source : models.py
with BSD 3-Clause "New" or "Revised" License
from aminalaee
with BSD 3-Clause "New" or "Revised" License
from aminalaee
async def get_model_by_pk(self, value: Any) -> Any:
stmt = select(self.model).where(
self.pk_column == self._get_column_python_type(self.pk_column)(value)
)
for _, relation in self._details_relations:
stmt = stmt.options(selectinload(relation.key))
rows = await self._run_query(stmt)
if rows:
return rows[0]
return None
def get_attr_value(
3
Source : test_select.py
with MIT License
from analyzeDFIR
with MIT License
from analyzeDFIR
def test_plain_union(self):
table = self.tables.some_table
s1 = select([table]).where(table.c.id == 2)
s2 = select([table]).where(table.c.id == 3)
u1 = union(s1, s2)
self._assert_result(
u1.order_by(u1.c.id),
[(2, 2, 3), (3, 3, 4)]
)
def test_select_from_plain_union(self):
3
Source : test_select.py
with MIT License
from analyzeDFIR
with MIT License
from analyzeDFIR
def test_select_from_plain_union(self):
table = self.tables.some_table
s1 = select([table]).where(table.c.id == 2)
s2 = select([table]).where(table.c.id == 3)
u1 = union(s1, s2).alias().select()
self._assert_result(
u1.order_by(u1.c.id),
[(2, 2, 3), (3, 3, 4)]
)
@testing.requires.order_by_col_from_union
3
Source : test_select.py
with MIT License
from analyzeDFIR
with MIT License
from analyzeDFIR
def test_limit_offset_selectable_in_unions(self):
table = self.tables.some_table
s1 = select([table]).where(table.c.id == 2).\
limit(1).order_by(table.c.id)
s2 = select([table]).where(table.c.id == 3).\
limit(1).order_by(table.c.id)
u1 = union(s1, s2).limit(2)
self._assert_result(
u1.order_by(u1.c.id),
[(2, 2, 3), (3, 3, 4)]
)
@testing.requires.parens_in_union_contained_select_wo_limit_offset
3
Source : test_select.py
with MIT License
from analyzeDFIR
with MIT License
from analyzeDFIR
def test_order_by_selectable_in_unions(self):
table = self.tables.some_table
s1 = select([table]).where(table.c.id == 2).\
order_by(table.c.id)
s2 = select([table]).where(table.c.id == 3).\
order_by(table.c.id)
u1 = union(s1, s2).limit(2)
self._assert_result(
u1.order_by(u1.c.id),
[(2, 2, 3), (3, 3, 4)]
)
def test_distinct_selectable_in_unions(self):
3
Source : test_select.py
with MIT License
from analyzeDFIR
with MIT License
from analyzeDFIR
def test_distinct_selectable_in_unions(self):
table = self.tables.some_table
s1 = select([table]).where(table.c.id == 2).\
distinct()
s2 = select([table]).where(table.c.id == 3).\
distinct()
u1 = union(s1, s2).limit(2)
self._assert_result(
u1.order_by(u1.c.id),
[(2, 2, 3), (3, 3, 4)]
)
@testing.requires.parens_in_union_contained_select_w_limit_offset
3
Source : test_select.py
with MIT License
from analyzeDFIR
with MIT License
from analyzeDFIR
def test_limit_offset_in_unions_from_alias(self):
table = self.tables.some_table
s1 = select([table]).where(table.c.id == 2).\
limit(1).order_by(table.c.id)
s2 = select([table]).where(table.c.id == 3).\
limit(1).order_by(table.c.id)
# this necessarily has double parens
u1 = union(s1, s2).alias()
self._assert_result(
u1.select().limit(2).order_by(u1.c.id),
[(2, 2, 3), (3, 3, 4)]
)
def test_limit_offset_aliased_selectable_in_unions(self):
3
Source : test_select.py
with MIT License
from analyzeDFIR
with MIT License
from analyzeDFIR
def test_limit_offset_aliased_selectable_in_unions(self):
table = self.tables.some_table
s1 = select([table]).where(table.c.id == 2).\
limit(1).order_by(table.c.id).alias().select()
s2 = select([table]).where(table.c.id == 3).\
limit(1).order_by(table.c.id).alias().select()
u1 = union(s1, s2).limit(2)
self._assert_result(
u1.order_by(u1.c.id),
[(2, 2, 3), (3, 3, 4)]
)
class ExpandingBoundInTest(fixtures.TablesTest):
3
Source : test_select.py
with MIT License
from analyzeDFIR
with MIT License
from analyzeDFIR
def test_bound_in_scalar(self):
table = self.tables.some_table
stmt = select([table.c.id]).where(
table.c.x.in_(bindparam('q', expanding=True))).order_by(table.c.id)
self._assert_result(
stmt,
[(2, ), (3, ), (4, )],
params={"q": [2, 3, 4]},
)
@testing.requires.tuple_in
3
Source : test_select.py
with MIT License
from analyzeDFIR
with MIT License
from analyzeDFIR
def test_bound_in_two_tuple(self):
table = self.tables.some_table
stmt = select([table.c.id]).where(
tuple_(table.c.x, table.c.y).in_(bindparam('q', expanding=True))).order_by(table.c.id)
self._assert_result(
stmt,
[(2, ), (3, ), (4, )],
params={"q": [(2, 3), (3, 4), (4, 5)]},
)
class LikeFunctionsTest(fixtures.TablesTest):
3
Source : test_select.py
with MIT License
from analyzeDFIR
with MIT License
from analyzeDFIR
def _test(self, expr, expected):
some_table = self.tables.some_table
with config.db.connect() as conn:
rows = {
value for value, in
conn.execute(select([some_table.c.id]).where(expr))
}
eq_(rows, expected)
def test_startswith_unescaped(self):
3
Source : test_types.py
with MIT License
from analyzeDFIR
with MIT License
from analyzeDFIR
def _test_index_criteria(self, crit, expected, test_literal=True):
self._criteria_fixture()
with config.db.connect() as conn:
stmt = select([self.tables.data_table.c.name]).where(crit)
eq_(
conn.scalar(stmt),
expected
)
if test_literal:
literal_sql = str(stmt.compile(
config.db, compile_kwargs={"literal_binds": True}))
eq_(conn.scalar(literal_sql), expected)
def test_crit_spaces_in_key(self):
3
Source : elevation.py
with GNU Affero General Public License v3.0
from andrewcooke
with GNU Affero General Public License v3.0
from andrewcooke
def __create_utm_srid(self, s, ajournal):
table = ActivityJournal.__table__
query = select([table.c.centre]).where(table.c.id == ajournal.id)
log.debug(query)
row = s.execute(query).fetchone()
lon, lat = to_shape(row[0]).coords[0]
srid = utm_srid(lat, lon)
update = table.update().values(utm_srid=srid).where(table.c.id == ajournal.id)
log.debug(update)
s.execute(update)
def __create_centre(self, s, ajournal):
3
Source : job_applicant.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_alias_in_sandbox(
self, sandbox_id: UUID, alias: str
) -> Type[ApplicantRead]:
q = (
select(self._table)
.where(self._table.sandbox_id == sandbox_id)
.where(self._table.alias == alias)
)
result = await self._db_session.execute(q)
student = result.scalar_one_or_none()
if not student:
return None
return self._schema.from_orm(student)
async def get_by_name_in_sandbox(
3
Source : job_applicant.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_name_in_sandbox(
self, sandbox_id: UUID, name: str
) -> Type[ApplicantRead]:
q = (
select(self._table)
.where(self._table.sandbox_id == sandbox_id)
.where(self._table.name == name)
)
result = await self._db_session.execute(q)
student = result.scalar_one_or_none()
if not student:
return None
return self._schema.from_orm(student)
async def get_by_id_in_sandbox(
3
Source : job_applicant.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_id_in_sandbox(
self, sandbox_id: UUID, applicant_id: UUID
) -> ApplicantRead:
q = (
select(self._table)
.where(self._table.sandbox_id == sandbox_id)
.where(self._table.id == applicant_id)
)
result = await self._db_session.execute(q)
entry = result.scalars().one_or_none()
if not entry:
raise DoesNotExist(
f"{self._table.__name__} < id:{applicant_id}> does not exist"
)
return ApplicantRead.from_orm(entry)
async def get_in_sandbox(self, sandbox_id: UUID) -> List[ApplicantRead]:
3
Source : line_of_business.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_id_with_sandbox(
self, sandbox_id: UUID, entry_id: UUID
) -> LobReadWithSandbox:
q = (
select(self._table)
.where(self._table.id == entry_id)
.where(self._table.sandbox_id == sandbox_id)
.options(selectinload(Lob.sandbox))
)
result = await self._db_session.execute(q)
item = result.scalars().one_or_none()
if not item:
raise DoesNotExist(f"{self._table.__name__} < id:{entry_id}> does not exist")
return LobReadWithSandbox.from_orm(item)
async def get_by_name_with_sandbox(
3
Source : line_of_business.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_name_with_sandbox(
self, sandbox_id: UUID, name: str
) -> LobReadWithSandbox:
q = (
select(self._table)
.where(self._table.name == name)
.where(self._table.sandbox_id == sandbox_id)
.options(selectinload(Lob.sandbox))
)
result = await self._db_session.execute(q)
item = result.scalars().one_or_none()
if not item:
raise DoesNotExist(f"{self._table.__name__} < name:{name}> does not exist")
return LobReadWithSandbox.from_orm(item)
async def get_in_sandbox(self, sandbox_id: UUID) -> List[LobReadWithSandbox]:
3
Source : line_of_business.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_in_sandbox(self, sandbox_id: UUID) -> List[LobReadWithSandbox]:
q = (
select(self._table)
.where(self._table.sandbox_id == sandbox_id)
.options(selectinload(Lob.sandbox))
)
result = await self._db_session.execute(q)
items = result.scalars().all()
return parse_obj_as(List[LobReadWithSandbox], items)
3
Source : out_of_band.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_in_sandbox(self, sandbox_id: UUID) -> List[OutOfBandReadPopulated]:
q = (
select(self._table)
.where(self._table.sandbox_id == sandbox_id)
.options(selectinload(OutOfBand.sender), selectinload(OutOfBand.recipient))
)
result = await self._db_session.execute(q)
items = result.scalars().all()
return parse_obj_as(List[OutOfBandReadPopulated], items)
async def get_by_sender(self, sender_id: UUID) -> List[OutOfBandRead]:
3
Source : out_of_band.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_sender(self, sender_id: UUID) -> List[OutOfBandRead]:
q = (
select(self._table)
.where(self._table.sender_id == sender_id)
.order_by(OutOfBand.created_at.desc())
)
result = await self._db_session.execute(q)
items = result.scalars().all()
return parse_obj_as(List[OutOfBandRead], items)
async def get_by_recipient(self, recipient_id: UUID) -> List[OutOfBandRead]:
3
Source : out_of_band.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_recipient(self, recipient_id: UUID) -> List[OutOfBandRead]:
q = (
select(self._table)
.where(self._table.recipient_id == recipient_id)
.order_by(OutOfBand.created_at.desc())
)
result = await self._db_session.execute(q)
items = result.scalars().all()
return parse_obj_as(List[OutOfBandRead], items)
async def get_for_lob(self, lob_id: UUID) -> List[OutOfBandReadPopulated]:
3
Source : out_of_band.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_for_lob(self, lob_id: UUID) -> List[OutOfBandReadPopulated]:
q = (
select(self._table)
.where(
or_(
self._table.recipient_id == lob_id,
self._table.sender_id == lob_id,
)
)
.order_by(OutOfBand.created_at.desc())
)
result = await self._db_session.execute(q)
items = result.scalars().all()
return parse_obj_as(List[OutOfBandReadPopulated], items)
3
Source : sandbox.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_id_populated(self, entry_id: UUID) -> SandboxReadPopulated:
q = (
select(self._table)
.where(self._table.id == entry_id)
.options(
selectinload(Sandbox.lobs),
selectinload(Sandbox.students),
selectinload(Sandbox.applicants),
)
)
result = await self._db_session.execute(q)
item = result.scalars().one_or_none()
if not item:
raise DoesNotExist(f"{self._table.__name__} < id:{entry_id}> does not exist")
return SandboxReadPopulated.from_orm(item)
async def find_populated(
3
Source : student.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_alias_in_sandbox(
self, sandbox_id: UUID, alias: str
) -> Type[StudentRead]:
q = (
select(self._table)
.where(self._table.sandbox_id == sandbox_id)
.where(self._table.alias == alias)
)
result = await self._db_session.execute(q)
student = result.scalar_one_or_none()
if not student:
return None
return self._schema.from_orm(student)
async def get_by_name_in_sandbox(
3
Source : student.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_name_in_sandbox(
self, sandbox_id: UUID, name: str
) -> Type[StudentRead]:
q = (
select(self._table)
.where(self._table.sandbox_id == sandbox_id)
.where(self._table.name == name)
)
result = await self._db_session.execute(q)
student = result.scalar_one_or_none()
if not student:
return None
return self._schema.from_orm(student)
async def get_by_id_in_sandbox(
3
Source : student.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_id_in_sandbox(
self, sandbox_id: UUID, student_id: UUID
) -> StudentRead:
q = (
select(self._table)
.where(self._table.sandbox_id == sandbox_id)
.where(self._table.id == student_id)
)
result = await self._db_session.execute(q)
entry = result.scalars().one_or_none()
if not entry:
raise DoesNotExist(
f"{self._table.__name__} < id:{student_id}> does not exist"
)
return StudentRead.from_orm(entry)
async def get_in_sandbox(self, sandbox_id: UUID) -> List[StudentRead]:
3
Source : webhooks.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_lob(lob_id, db):
# we want data that should not be in LobRead (private wallet information)
_q = select(Lob).where(Lob.id == lob_id)
_rec = await db.execute(_q)
lob = _rec.scalars().one_or_none()
if not lob:
raise DoesNotExist(f"{Lob.__name__} < id:{lob_id}> does not exist")
return lob
api_key_header = APIKeyHeader(
3
Source : sandbox.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_line_of_business(sandbox, lob_id, db) -> Lob:
# we want data that should not be in LobRead (private wallet information)
_q = select(Lob).where(Lob.id == lob_id).where(Lob.sandbox_id == sandbox.id)
_rec = await db.execute(_q)
entity = _rec.scalars().one_or_none()
if not entity:
raise DoesNotExist(f"{Lob.__name__} < id:{lob_id}> does not exist")
return entity
async def create_new_line_of_business(
3
Source : issue_credentials.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def find_by_tenant_id(
self, tenant_id: UUID, offset: int = 0, limit: int = 100
) -> List[IssueCredentialRead]:
# not sure how to make this into a generic search function
q = (
select(self._table)
.where(self._table.tenant_id == tenant_id)
.offset(offset)
.limit(limit)
)
result = await self._db_session.execute(q)
items = result.scalars().all()
return parse_obj_as(List[IssueCredentialRead], items)
async def find_by_wallet_id(
3
Source : issue_credentials.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def find_by_wallet_id(
self, wallet_id: UUID, offset: int = 0, limit: int = 100
) -> List[IssueCredentialRead]:
# not sure how to make this into a generic search function
q = (
select(self._table)
.where(self._table.wallet_id == wallet_id)
.offset(offset)
.limit(limit)
)
result = await self._db_session.execute(q)
items = result.scalars().all()
return parse_obj_as(List[IssueCredentialRead], items)
async def find_by_wallet_id_and_role(
3
Source : issue_credentials.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def find_by_wallet_id_and_role(
self, wallet_id: UUID, role: str, offset: int = 0, limit: int = 100
) -> List[IssueCredentialRead]:
# not sure how to make this into a generic search function
q = (
select(self._table)
.where(self._table.wallet_id == wallet_id)
.where(self._table.issue_role == role)
.offset(offset)
.limit(limit)
)
result = await self._db_session.execute(q)
items = result.scalars().all()
return parse_obj_as(List[IssueCredentialRead], items)
async def get_by_workflow_id(self, workflow_id: UUID) -> Type[IssueCredentialRead]:
3
Source : issue_credentials.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_workflow_id(self, workflow_id: UUID) -> Type[IssueCredentialRead]:
q = select(self._table).where(self._table.workflow_id == workflow_id)
result = await self._db_session.execute(q)
issue_cred = result.scalar_one_or_none()
if not issue_cred:
raise DoesNotExist(
f"{self._table.__name__} < workflow_id:{workflow_id}> does not exist"
)
return self._schema.from_orm(issue_cred)
async def get_by_cred_exch_id(
3
Source : issue_credentials.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_cred_exch_id(
self, cred_exch_id: UUID
) -> Type[IssueCredentialRead]:
q = select(self._table).where(self._table.cred_exch_id == cred_exch_id)
result = await self._db_session.execute(q)
issue_cred = result.scalar_one_or_none()
if not issue_cred:
raise DoesNotExist(
f"{self._table.__name__} < cred_exch_id:{cred_exch_id}> does not exist"
)
return self._schema.from_orm(issue_cred)
3
Source : present_credentials.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def find_by_tenant_id(
self, tenant_id: UUID, offset: int = 0, limit: int = 100
) -> List[PresentCredentialRead]:
# not sure how to make this into a generic search function
q = (
select(self._table)
.where(self._table.tenant_id == tenant_id)
.offset(offset)
.limit(limit)
)
result = await self._db_session.execute(q)
items = result.scalars().all()
return parse_obj_as(List[PresentCredentialRead], items)
async def find_by_wallet_id(
3
Source : present_credentials.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def find_by_wallet_id(
self, wallet_id: UUID, offset: int = 0, limit: int = 100
) -> List[PresentCredentialRead]:
# not sure how to make this into a generic search function
q = (
select(self._table)
.where(self._table.wallet_id == wallet_id)
.offset(offset)
.limit(limit)
)
result = await self._db_session.execute(q)
items = result.scalars().all()
return parse_obj_as(List[PresentCredentialRead], items)
async def find_by_wallet_id_and_role(
3
Source : present_credentials.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def find_by_wallet_id_and_role(
self, wallet_id: UUID, role: str, offset: int = 0, limit: int = 100
) -> List[PresentCredentialRead]:
# not sure how to make this into a generic search function
q = (
select(self._table)
.where(self._table.wallet_id == wallet_id)
.where(self._table.present_role == role)
.offset(offset)
.limit(limit)
)
result = await self._db_session.execute(q)
items = result.scalars().all()
return parse_obj_as(List[PresentCredentialRead], items)
async def get_by_workflow_id(
3
Source : present_credentials.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_workflow_id(
self, workflow_id: UUID
) -> Type[PresentCredentialRead]:
q = select(self._table).where(self._table.workflow_id == workflow_id)
result = await self._db_session.execute(q)
present_cred = result.scalar_one_or_none()
if not present_cred:
raise DoesNotExist(
f"{self._table.__name__} < workflow_id:{workflow_id}> does not exist"
)
return self._schema.from_orm(present_cred)
async def get_by_pres_exch_id(
3
Source : present_credentials.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_pres_exch_id(
self, pres_exch_id: UUID
) -> Type[PresentCredentialRead]:
q = select(self._table).where(self._table.pres_exch_id == pres_exch_id)
result = await self._db_session.execute(q)
present_cred = result.scalar_one_or_none()
if not present_cred:
raise DoesNotExist(
f"{self._table.__name__} < pres_exch_id:{pres_exch_id}> does not exist"
)
return self._schema.from_orm(present_cred)
3
Source : tenants.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_name(self, name: str) -> Type[TenantRead]:
q = select(self._table).where(self._table.name == name)
result = await self._db_session.execute(q)
tenant = result.scalar_one_or_none()
if not tenant:
return None
return self._schema.from_orm(tenant)
async def get_by_wallet_id(self, wallet_id: UUID) -> Type[TenantRead]:
3
Source : tenants.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_wallet_id(self, wallet_id: UUID) -> Type[TenantRead]:
q = select(self._table).where(self._table.wallet_id == wallet_id)
result = await self._db_session.execute(q)
tenant = result.scalar_one_or_none()
if not tenant:
raise DoesNotExist(
f"{self._table.__name__} < wallet_id:{wallet_id}> does not exist"
)
return self._schema.from_orm(tenant)
3
Source : tenant_issuers.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_tenant_id(self, tenant_id: UUID) -> Type[TenantIssuerRead]:
q = select(self._table).where(self._table.tenant_id == tenant_id)
result = await self._db_session.execute(q)
tenant_issuer = result.scalar_one_or_none()
if not tenant_issuer:
raise DoesNotExist(
f"{self._table.__name__} < tenant_id:{tenant_id}> does not exist"
)
return self._schema.from_orm(tenant_issuer)
async def get_by_wallet_id(self, wallet_id: UUID) -> Type[TenantIssuerRead]:
3
Source : tenant_issuers.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_wallet_id(self, wallet_id: UUID) -> Type[TenantIssuerRead]:
q = select(self._table).where(self._table.wallet_id == wallet_id)
result = await self._db_session.execute(q)
tenant_issuer = result.scalar_one_or_none()
if not tenant_issuer:
raise DoesNotExist(
f"{self._table.__name__} < wallet_id:{wallet_id}> does not exist"
)
return self._schema.from_orm(tenant_issuer)
async def get_by_workflow_id(self, workflow_id: UUID) -> Type[TenantIssuerRead]:
3
Source : tenant_issuers.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_workflow_id(self, workflow_id: UUID) -> Type[TenantIssuerRead]:
q = select(self._table).where(self._table.workflow_id == workflow_id)
result = await self._db_session.execute(q)
tenant_issuer = result.scalar_one_or_none()
if not tenant_issuer:
raise DoesNotExist(
f"{self._table.__name__} < workflow_id:{workflow_id}> does not exist"
)
return self._schema.from_orm(tenant_issuer)
async def get_by_wallet_and_endorser_connection_id(
3
Source : tenant_issuers.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def get_by_wallet_and_endorser_connection_id(
self, wallet_id: UUID, endorser_connection_id: UUID
) -> Type[TenantIssuerRead]:
q = (
select(self._table)
.where(self._table.wallet_id == wallet_id)
.where(self._table.endorser_connection_id == endorser_connection_id)
)
result = await self._db_session.execute(q)
tenant_issuer = result.scalar_one_or_none()
if not tenant_issuer:
raise DoesNotExist(
(
f"{self._table.__name__} < wallet_id:{wallet_id}>"
f" < endorser_connection_id:{endorser_connection_id}> does not exist"
)
)
return self._schema.from_orm(tenant_issuer)
3
Source : tenant_schemas.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def find_by_tenant_id(
self, tenant_id: UUID, offset: int = 0, limit: int = 100
) -> List[TenantSchemaRead]:
# not sure how to make this into a generic search function
q = (
select(self._table)
.where(self._table.tenant_id == tenant_id)
.offset(offset)
.limit(limit)
)
result = await self._db_session.execute(q)
items = result.scalars().all()
return parse_obj_as(List[TenantSchemaRead], items)
async def find_by_wallet_id(
3
Source : tenant_schemas.py
with Apache License 2.0
from bcgov
with Apache License 2.0
from bcgov
async def find_by_wallet_id(
self, wallet_id: UUID, offset: int = 0, limit: int = 100
) -> List[TenantSchemaRead]:
# not sure how to make this into a generic search function
q = (
select(self._table)
.where(self._table.wallet_id == wallet_id)
.offset(offset)
.limit(limit)
)
result = await self._db_session.execute(q)
items = result.scalars().all()
return parse_obj_as(List[TenantSchemaRead], items)
async def get_by_workflow_id(self, workflow_id: UUID) -> Type[TenantSchemaRead]:
See More Examples