internal.queries.activity_log
1# Code generated by sqlc. DO NOT EDIT. 2# versions: 3# sqlc v1.30.0 4# source: activity_log.sql 5import pydantic 6from typing import Any, Optional 7 8import sqlalchemy 9import sqlalchemy.ext.asyncio 10 11from internal.queries import models 12 13 14CREATE_ACTIVITY_LOG = """-- name: create_activity_log \\:one 15INSERT INTO activity_log (user_id, action, details, ip_address) 16VALUES (:p1, :p2, :p3, :p4) 17RETURNING activity_id, user_id, action, details, ip_address, created_at 18""" 19 20 21class CreateActivityLogParams(pydantic.BaseModel): 22 user_id: Optional[int] 23 action: str 24 details: Optional[Any] 25 ip_address: str 26 27 28class AsyncQuerier: 29 def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection): 30 self._conn = conn 31 32 async def create_activity_log(self, arg: CreateActivityLogParams) -> Optional[models.ActivityLog]: 33 row = (await self._conn.execute(sqlalchemy.text(CREATE_ACTIVITY_LOG), { 34 "p1": arg.user_id, 35 "p2": arg.action, 36 "p3": arg.details, 37 "p4": arg.ip_address, 38 })).first() 39 if row is None: 40 return None 41 return models.ActivityLog( 42 activity_id=row[0], 43 user_id=row[1], 44 action=row[2], 45 details=row[3], 46 ip_address=row[4], 47 created_at=row[5], 48 )
CREATE_ACTIVITY_LOG =
'-- name: create_activity_log \\:one\nINSERT INTO activity_log (user_id, action, details, ip_address)\nVALUES (:p1, :p2, :p3, :p4)\nRETURNING activity_id, user_id, action, details, ip_address, created_at\n'
class
CreateActivityLogParams(pydantic.main.BaseModel):
22class CreateActivityLogParams(pydantic.BaseModel): 23 user_id: Optional[int] 24 action: str 25 details: Optional[Any] 26 ip_address: str
!!! abstract "Usage Documentation" Models
A base class for creating Pydantic models.
Attributes:
- __class_vars__: The names of the class variables defined on the model.
- __private_attributes__: Metadata about the private attributes of the model.
- __signature__: The synthesized
__init__[Signature][inspect.Signature] of the model. - __pydantic_complete__: Whether model building is completed, or if there are still undefined fields.
- __pydantic_core_schema__: The core schema of the model.
- __pydantic_custom_init__: Whether the model has a custom
__init__function. - __pydantic_decorators__: Metadata containing the decorators defined on the model.
This replaces
Model.__validators__andModel.__root_validators__from Pydantic V1. - __pydantic_generic_metadata__: Metadata for generic models; contains data used for a similar purpose to __args__, __origin__, __parameters__ in typing-module generics. May eventually be replaced by these.
- __pydantic_parent_namespace__: Parent namespace of the model, used for automatic rebuilding of models.
- __pydantic_post_init__: The name of the post-init method for the model, if defined.
- __pydantic_root_model__: Whether the model is a [
RootModel][pydantic.root_model.RootModel]. - __pydantic_serializer__: The
pydantic-coreSchemaSerializerused to dump instances of the model. - __pydantic_validator__: The
pydantic-coreSchemaValidatorused to validate instances of the model. - __pydantic_fields__: A dictionary of field names and their corresponding [
FieldInfo][pydantic.fields.FieldInfo] objects. - __pydantic_computed_fields__: A dictionary of computed field names and their corresponding [
ComputedFieldInfo][pydantic.fields.ComputedFieldInfo] objects. - __pydantic_extra__: A dictionary containing extra values, if [
extra][pydantic.config.ConfigDict.extra] is set to'allow'. - __pydantic_fields_set__: The names of fields explicitly set during instantiation.
- __pydantic_private__: Values of private attributes set on the model instance.
class
AsyncQuerier:
29class AsyncQuerier: 30 def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection): 31 self._conn = conn 32 33 async def create_activity_log(self, arg: CreateActivityLogParams) -> Optional[models.ActivityLog]: 34 row = (await self._conn.execute(sqlalchemy.text(CREATE_ACTIVITY_LOG), { 35 "p1": arg.user_id, 36 "p2": arg.action, 37 "p3": arg.details, 38 "p4": arg.ip_address, 39 })).first() 40 if row is None: 41 return None 42 return models.ActivityLog( 43 activity_id=row[0], 44 user_id=row[1], 45 action=row[2], 46 details=row[3], 47 ip_address=row[4], 48 created_at=row[5], 49 )
async def
create_activity_log( self, arg: CreateActivityLogParams) -> internal.queries.models.ActivityLog | None:
33 async def create_activity_log(self, arg: CreateActivityLogParams) -> Optional[models.ActivityLog]: 34 row = (await self._conn.execute(sqlalchemy.text(CREATE_ACTIVITY_LOG), { 35 "p1": arg.user_id, 36 "p2": arg.action, 37 "p3": arg.details, 38 "p4": arg.ip_address, 39 })).first() 40 if row is None: 41 return None 42 return models.ActivityLog( 43 activity_id=row[0], 44 user_id=row[1], 45 action=row[2], 46 details=row[3], 47 ip_address=row[4], 48 created_at=row[5], 49 )