internal.queries.user

  1# Code generated by sqlc. DO NOT EDIT.
  2# versions:
  3#   sqlc v1.30.0
  4# source: user.sql
  5import datetime
  6import decimal
  7import pydantic
  8from typing import AsyncIterator, Optional
  9
 10import sqlalchemy
 11import sqlalchemy.ext.asyncio
 12
 13from internal.queries import models
 14
 15
 16CREATE_USER = """-- name: create_user \\:one
 17INSERT INTO users (email, username, pw_hash, role)
 18VALUES (:p1, :p2, :p3, :p4)
 19RETURNING user_id, username, email, role, created_at
 20"""
 21
 22
 23class CreateUserParams(pydantic.BaseModel):
 24    email: str
 25    username: str
 26    pw_hash: str
 27    role: models.UserRole
 28
 29
 30class CreateUserRow(pydantic.BaseModel):
 31    user_id: int
 32    username: str
 33    email: str
 34    role: models.UserRole
 35    created_at: datetime.datetime
 36
 37
 38DELETE_USER = """-- name: delete_user \\:one
 39DELETE FROM users
 40WHERE user_id = :p1
 41RETURNING user_id, username, email, role, created_at
 42"""
 43
 44
 45class DeleteUserRow(pydantic.BaseModel):
 46    user_id: int
 47    username: str
 48    email: str
 49    role: models.UserRole
 50    created_at: datetime.datetime
 51
 52
 53GET_USER = """-- name: get_user \\:one
 54SELECT user_id, username, email, role, created_at
 55FROM users
 56WHERE user_id = :p1 
 57LIMIT 1
 58"""
 59
 60
 61class GetUserRow(pydantic.BaseModel):
 62    user_id: int
 63    username: str
 64    email: str
 65    role: models.UserRole
 66    created_at: datetime.datetime
 67
 68
 69GET_USER_ID = """-- name: get_user_id \\:one
 70SELECT user_id, role
 71FROM users
 72WHERE username=:p1
 73LIMIT 1
 74"""
 75
 76
 77class GetUserIdRow(pydantic.BaseModel):
 78    user_id: int
 79    role: models.UserRole
 80
 81
 82GET_USER_LOGIN = """-- name: get_user_login \\:one
 83SELECT user_id, username, email, pw_hash, role
 84FROM users
 85WHERE email = :p1
 86LIMIT 1
 87"""
 88
 89
 90class GetUserLoginRow(pydantic.BaseModel):
 91    user_id: int
 92    username: str
 93    email: str
 94    pw_hash: str
 95    role: models.UserRole
 96
 97
 98GET_USERS = """-- name: get_users \\:many
 99SELECT user_id, username, email, role, created_at, last_login
100FROM users
101"""
102
103
104class GetUsersRow(pydantic.BaseModel):
105    user_id: int
106    username: str
107    email: str
108    role: models.UserRole
109    created_at: datetime.datetime
110    last_login: datetime.datetime
111
112
113LEADERBOARD_CARBON_DIOXIDE = """-- name: leaderboard_carbon_dioxide \\:many
114SELECT u.username, COALESCE(SUM(b.carbon_dioxide), 0)\\:\\:numeric AS total_carbon_dioxide
115FROM users u
116LEFT JOIN reservations r ON r.consumer_id = u.user_id
117LEFT JOIN bundles b ON b.bundle_id = r.bundle_id
118GROUP BY u.user_id, u.username
119ORDER BY total_carbon_dioxide DESC
120LIMIT :p1
121"""
122
123
124class LeaderboardCarbonDioxideRow(pydantic.BaseModel):
125    username: str
126    total_carbon_dioxide: decimal.Decimal
127
128
129LEADERBOARD_RESERVATIONS = """-- name: leaderboard_reservations \\:many
130SELECT u.username, COUNT(r.reservation_id) AS reservation_count
131FROM users u
132LEFT JOIN reservations r ON r.consumer_id = u.user_id
133GROUP BY u.user_id, u.username
134ORDER BY reservation_count DESC
135LIMIT :p1
136"""
137
138
139class LeaderboardReservationsRow(pydantic.BaseModel):
140    username: str
141    reservation_count: int
142
143
144UPDATE_USER_EMAIL = """-- name: update_user_email \\:one
145UPDATE users
146SET email=:p2
147WHERE user_id=:p1
148RETURNING user_id, username, email, role, created_at
149"""
150
151
152class UpdateUserEmailParams(pydantic.BaseModel):
153    user_id: int
154    email: str
155
156
157class UpdateUserEmailRow(pydantic.BaseModel):
158    user_id: int
159    username: str
160    email: str
161    role: models.UserRole
162    created_at: datetime.datetime
163
164
165UPDATE_USER_PASSWORD = """-- name: update_user_password \\:one
166UPDATE users
167SET pw_hash=:p2
168WHERE user_id=:p1
169RETURNING user_id, username, email, role, created_at
170"""
171
172
173class UpdateUserPasswordParams(pydantic.BaseModel):
174    user_id: int
175    pw_hash: str
176
177
178class UpdateUserPasswordRow(pydantic.BaseModel):
179    user_id: int
180    username: str
181    email: str
182    role: models.UserRole
183    created_at: datetime.datetime
184
185
186class AsyncQuerier:
187    def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
188        self._conn = conn
189
190    async def create_user(self, arg: CreateUserParams) -> Optional[CreateUserRow]:
191        row = (await self._conn.execute(sqlalchemy.text(CREATE_USER), {
192            "p1": arg.email,
193            "p2": arg.username,
194            "p3": arg.pw_hash,
195            "p4": arg.role,
196        })).first()
197        if row is None:
198            return None
199        return CreateUserRow(
200            user_id=row[0],
201            username=row[1],
202            email=row[2],
203            role=row[3],
204            created_at=row[4],
205        )
206
207    async def delete_user(self, *, user_id: int) -> Optional[DeleteUserRow]:
208        row = (await self._conn.execute(sqlalchemy.text(DELETE_USER), {"p1": user_id})).first()
209        if row is None:
210            return None
211        return DeleteUserRow(
212            user_id=row[0],
213            username=row[1],
214            email=row[2],
215            role=row[3],
216            created_at=row[4],
217        )
218
219    async def get_user(self, *, user_id: int) -> Optional[GetUserRow]:
220        row = (await self._conn.execute(sqlalchemy.text(GET_USER), {"p1": user_id})).first()
221        if row is None:
222            return None
223        return GetUserRow(
224            user_id=row[0],
225            username=row[1],
226            email=row[2],
227            role=row[3],
228            created_at=row[4],
229        )
230
231    async def get_user_id(self, *, username: str) -> Optional[GetUserIdRow]:
232        row = (await self._conn.execute(sqlalchemy.text(GET_USER_ID), {"p1": username})).first()
233        if row is None:
234            return None
235        return GetUserIdRow(
236            user_id=row[0],
237            role=row[1],
238        )
239
240    async def get_user_login(self, *, email: str) -> Optional[GetUserLoginRow]:
241        row = (await self._conn.execute(sqlalchemy.text(GET_USER_LOGIN), {"p1": email})).first()
242        if row is None:
243            return None
244        return GetUserLoginRow(
245            user_id=row[0],
246            username=row[1],
247            email=row[2],
248            pw_hash=row[3],
249            role=row[4],
250        )
251
252    async def get_users(self) -> AsyncIterator[GetUsersRow]:
253        result = await self._conn.stream(sqlalchemy.text(GET_USERS))
254        async for row in result:
255            yield GetUsersRow(
256                user_id=row[0],
257                username=row[1],
258                email=row[2],
259                role=row[3],
260                created_at=row[4],
261                last_login=row[5],
262            )
263
264    async def leaderboard_carbon_dioxide(self, *, limit: int) -> AsyncIterator[LeaderboardCarbonDioxideRow]:
265        result = await self._conn.stream(sqlalchemy.text(LEADERBOARD_CARBON_DIOXIDE), {"p1": limit})
266        async for row in result:
267            yield LeaderboardCarbonDioxideRow(
268                username=row[0],
269                total_carbon_dioxide=row[1],
270            )
271
272    async def leaderboard_reservations(self, *, limit: int) -> AsyncIterator[LeaderboardReservationsRow]:
273        result = await self._conn.stream(sqlalchemy.text(LEADERBOARD_RESERVATIONS), {"p1": limit})
274        async for row in result:
275            yield LeaderboardReservationsRow(
276                username=row[0],
277                reservation_count=row[1],
278            )
279
280    async def update_user_email(self, arg: UpdateUserEmailParams) -> Optional[UpdateUserEmailRow]:
281        row = (await self._conn.execute(sqlalchemy.text(UPDATE_USER_EMAIL), {"p1": arg.user_id, "p2": arg.email})).first()
282        if row is None:
283            return None
284        return UpdateUserEmailRow(
285            user_id=row[0],
286            username=row[1],
287            email=row[2],
288            role=row[3],
289            created_at=row[4],
290        )
291
292    async def update_user_password(self, arg: UpdateUserPasswordParams) -> Optional[UpdateUserPasswordRow]:
293        row = (await self._conn.execute(sqlalchemy.text(UPDATE_USER_PASSWORD), {"p1": arg.user_id, "p2": arg.pw_hash})).first()
294        if row is None:
295            return None
296        return UpdateUserPasswordRow(
297            user_id=row[0],
298            username=row[1],
299            email=row[2],
300            role=row[3],
301            created_at=row[4],
302        )
CREATE_USER = '-- name: create_user \\:one\nINSERT INTO users (email, username, pw_hash, role)\nVALUES (:p1, :p2, :p3, :p4)\nRETURNING user_id, username, email, role, created_at\n'
class CreateUserParams(pydantic.main.BaseModel):
24class CreateUserParams(pydantic.BaseModel):
25    email: str
26    username: str
27    pw_hash: str
28    role: models.UserRole

!!! 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__ and Model.__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-core SchemaSerializer used to dump instances of the model.
  • __pydantic_validator__: The pydantic-core SchemaValidator used 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.
email: str = PydanticUndefined
username: str = PydanticUndefined
pw_hash: str = PydanticUndefined
role: internal.queries.models.UserRole = PydanticUndefined
class CreateUserRow(pydantic.main.BaseModel):
31class CreateUserRow(pydantic.BaseModel):
32    user_id: int
33    username: str
34    email: str
35    role: models.UserRole
36    created_at: datetime.datetime

!!! 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__ and Model.__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-core SchemaSerializer used to dump instances of the model.
  • __pydantic_validator__: The pydantic-core SchemaValidator used 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.
user_id: int = PydanticUndefined
username: str = PydanticUndefined
email: str = PydanticUndefined
role: internal.queries.models.UserRole = PydanticUndefined
created_at: datetime.datetime = PydanticUndefined
DELETE_USER = '-- name: delete_user \\:one\nDELETE FROM users\nWHERE user_id = :p1\nRETURNING user_id, username, email, role, created_at\n'
class DeleteUserRow(pydantic.main.BaseModel):
46class DeleteUserRow(pydantic.BaseModel):
47    user_id: int
48    username: str
49    email: str
50    role: models.UserRole
51    created_at: datetime.datetime

!!! 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__ and Model.__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-core SchemaSerializer used to dump instances of the model.
  • __pydantic_validator__: The pydantic-core SchemaValidator used 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.
user_id: int = PydanticUndefined
username: str = PydanticUndefined
email: str = PydanticUndefined
role: internal.queries.models.UserRole = PydanticUndefined
created_at: datetime.datetime = PydanticUndefined
GET_USER = '-- name: get_user \\:one\nSELECT user_id, username, email, role, created_at\nFROM users\nWHERE user_id = :p1 \nLIMIT 1\n'
class GetUserRow(pydantic.main.BaseModel):
62class GetUserRow(pydantic.BaseModel):
63    user_id: int
64    username: str
65    email: str
66    role: models.UserRole
67    created_at: datetime.datetime

!!! 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__ and Model.__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-core SchemaSerializer used to dump instances of the model.
  • __pydantic_validator__: The pydantic-core SchemaValidator used 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.
user_id: int = PydanticUndefined
username: str = PydanticUndefined
email: str = PydanticUndefined
role: internal.queries.models.UserRole = PydanticUndefined
created_at: datetime.datetime = PydanticUndefined
GET_USER_ID = '-- name: get_user_id \\:one\nSELECT user_id, role\nFROM users\nWHERE username=:p1\nLIMIT 1\n'
class GetUserIdRow(pydantic.main.BaseModel):
78class GetUserIdRow(pydantic.BaseModel):
79    user_id: int
80    role: models.UserRole

!!! 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__ and Model.__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-core SchemaSerializer used to dump instances of the model.
  • __pydantic_validator__: The pydantic-core SchemaValidator used 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.
user_id: int = PydanticUndefined
role: internal.queries.models.UserRole = PydanticUndefined
GET_USER_LOGIN = '-- name: get_user_login \\:one\nSELECT user_id, username, email, pw_hash, role\nFROM users\nWHERE email = :p1\nLIMIT 1\n'
class GetUserLoginRow(pydantic.main.BaseModel):
91class GetUserLoginRow(pydantic.BaseModel):
92    user_id: int
93    username: str
94    email: str
95    pw_hash: str
96    role: models.UserRole

!!! 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__ and Model.__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-core SchemaSerializer used to dump instances of the model.
  • __pydantic_validator__: The pydantic-core SchemaValidator used 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.
user_id: int = PydanticUndefined
username: str = PydanticUndefined
email: str = PydanticUndefined
pw_hash: str = PydanticUndefined
role: internal.queries.models.UserRole = PydanticUndefined
GET_USERS = '-- name: get_users \\:many\nSELECT user_id, username, email, role, created_at, last_login\nFROM users\n'
class GetUsersRow(pydantic.main.BaseModel):
105class GetUsersRow(pydantic.BaseModel):
106    user_id: int
107    username: str
108    email: str
109    role: models.UserRole
110    created_at: datetime.datetime
111    last_login: datetime.datetime

!!! 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__ and Model.__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-core SchemaSerializer used to dump instances of the model.
  • __pydantic_validator__: The pydantic-core SchemaValidator used 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.
user_id: int = PydanticUndefined
username: str = PydanticUndefined
email: str = PydanticUndefined
role: internal.queries.models.UserRole = PydanticUndefined
created_at: datetime.datetime = PydanticUndefined
last_login: datetime.datetime = PydanticUndefined
LEADERBOARD_CARBON_DIOXIDE = '-- name: leaderboard_carbon_dioxide \\:many\nSELECT u.username, COALESCE(SUM(b.carbon_dioxide), 0)\\:\\:numeric AS total_carbon_dioxide\nFROM users u\nLEFT JOIN reservations r ON r.consumer_id = u.user_id\nLEFT JOIN bundles b ON b.bundle_id = r.bundle_id\nGROUP BY u.user_id, u.username\nORDER BY total_carbon_dioxide DESC\nLIMIT :p1\n'
class LeaderboardCarbonDioxideRow(pydantic.main.BaseModel):
125class LeaderboardCarbonDioxideRow(pydantic.BaseModel):
126    username: str
127    total_carbon_dioxide: decimal.Decimal

!!! 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__ and Model.__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-core SchemaSerializer used to dump instances of the model.
  • __pydantic_validator__: The pydantic-core SchemaValidator used 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.
username: str = PydanticUndefined
total_carbon_dioxide: decimal.Decimal = PydanticUndefined
LEADERBOARD_RESERVATIONS = '-- name: leaderboard_reservations \\:many\nSELECT u.username, COUNT(r.reservation_id) AS reservation_count\nFROM users u\nLEFT JOIN reservations r ON r.consumer_id = u.user_id\nGROUP BY u.user_id, u.username\nORDER BY reservation_count DESC\nLIMIT :p1\n'
class LeaderboardReservationsRow(pydantic.main.BaseModel):
140class LeaderboardReservationsRow(pydantic.BaseModel):
141    username: str
142    reservation_count: int

!!! 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__ and Model.__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-core SchemaSerializer used to dump instances of the model.
  • __pydantic_validator__: The pydantic-core SchemaValidator used 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.
username: str = PydanticUndefined
reservation_count: int = PydanticUndefined
UPDATE_USER_EMAIL = '-- name: update_user_email \\:one\nUPDATE users\nSET email=:p2\nWHERE user_id=:p1\nRETURNING user_id, username, email, role, created_at\n'
class UpdateUserEmailParams(pydantic.main.BaseModel):
153class UpdateUserEmailParams(pydantic.BaseModel):
154    user_id: int
155    email: 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__ and Model.__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-core SchemaSerializer used to dump instances of the model.
  • __pydantic_validator__: The pydantic-core SchemaValidator used 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.
user_id: int = PydanticUndefined
email: str = PydanticUndefined
class UpdateUserEmailRow(pydantic.main.BaseModel):
158class UpdateUserEmailRow(pydantic.BaseModel):
159    user_id: int
160    username: str
161    email: str
162    role: models.UserRole
163    created_at: datetime.datetime

!!! 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__ and Model.__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-core SchemaSerializer used to dump instances of the model.
  • __pydantic_validator__: The pydantic-core SchemaValidator used 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.
user_id: int = PydanticUndefined
username: str = PydanticUndefined
email: str = PydanticUndefined
role: internal.queries.models.UserRole = PydanticUndefined
created_at: datetime.datetime = PydanticUndefined
UPDATE_USER_PASSWORD = '-- name: update_user_password \\:one\nUPDATE users\nSET pw_hash=:p2\nWHERE user_id=:p1\nRETURNING user_id, username, email, role, created_at\n'
class UpdateUserPasswordParams(pydantic.main.BaseModel):
174class UpdateUserPasswordParams(pydantic.BaseModel):
175    user_id: int
176    pw_hash: 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__ and Model.__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-core SchemaSerializer used to dump instances of the model.
  • __pydantic_validator__: The pydantic-core SchemaValidator used 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.
user_id: int = PydanticUndefined
pw_hash: str = PydanticUndefined
class UpdateUserPasswordRow(pydantic.main.BaseModel):
179class UpdateUserPasswordRow(pydantic.BaseModel):
180    user_id: int
181    username: str
182    email: str
183    role: models.UserRole
184    created_at: datetime.datetime

!!! 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__ and Model.__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-core SchemaSerializer used to dump instances of the model.
  • __pydantic_validator__: The pydantic-core SchemaValidator used 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.
user_id: int = PydanticUndefined
username: str = PydanticUndefined
email: str = PydanticUndefined
role: internal.queries.models.UserRole = PydanticUndefined
created_at: datetime.datetime = PydanticUndefined
class AsyncQuerier:
187class AsyncQuerier:
188    def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
189        self._conn = conn
190
191    async def create_user(self, arg: CreateUserParams) -> Optional[CreateUserRow]:
192        row = (await self._conn.execute(sqlalchemy.text(CREATE_USER), {
193            "p1": arg.email,
194            "p2": arg.username,
195            "p3": arg.pw_hash,
196            "p4": arg.role,
197        })).first()
198        if row is None:
199            return None
200        return CreateUserRow(
201            user_id=row[0],
202            username=row[1],
203            email=row[2],
204            role=row[3],
205            created_at=row[4],
206        )
207
208    async def delete_user(self, *, user_id: int) -> Optional[DeleteUserRow]:
209        row = (await self._conn.execute(sqlalchemy.text(DELETE_USER), {"p1": user_id})).first()
210        if row is None:
211            return None
212        return DeleteUserRow(
213            user_id=row[0],
214            username=row[1],
215            email=row[2],
216            role=row[3],
217            created_at=row[4],
218        )
219
220    async def get_user(self, *, user_id: int) -> Optional[GetUserRow]:
221        row = (await self._conn.execute(sqlalchemy.text(GET_USER), {"p1": user_id})).first()
222        if row is None:
223            return None
224        return GetUserRow(
225            user_id=row[0],
226            username=row[1],
227            email=row[2],
228            role=row[3],
229            created_at=row[4],
230        )
231
232    async def get_user_id(self, *, username: str) -> Optional[GetUserIdRow]:
233        row = (await self._conn.execute(sqlalchemy.text(GET_USER_ID), {"p1": username})).first()
234        if row is None:
235            return None
236        return GetUserIdRow(
237            user_id=row[0],
238            role=row[1],
239        )
240
241    async def get_user_login(self, *, email: str) -> Optional[GetUserLoginRow]:
242        row = (await self._conn.execute(sqlalchemy.text(GET_USER_LOGIN), {"p1": email})).first()
243        if row is None:
244            return None
245        return GetUserLoginRow(
246            user_id=row[0],
247            username=row[1],
248            email=row[2],
249            pw_hash=row[3],
250            role=row[4],
251        )
252
253    async def get_users(self) -> AsyncIterator[GetUsersRow]:
254        result = await self._conn.stream(sqlalchemy.text(GET_USERS))
255        async for row in result:
256            yield GetUsersRow(
257                user_id=row[0],
258                username=row[1],
259                email=row[2],
260                role=row[3],
261                created_at=row[4],
262                last_login=row[5],
263            )
264
265    async def leaderboard_carbon_dioxide(self, *, limit: int) -> AsyncIterator[LeaderboardCarbonDioxideRow]:
266        result = await self._conn.stream(sqlalchemy.text(LEADERBOARD_CARBON_DIOXIDE), {"p1": limit})
267        async for row in result:
268            yield LeaderboardCarbonDioxideRow(
269                username=row[0],
270                total_carbon_dioxide=row[1],
271            )
272
273    async def leaderboard_reservations(self, *, limit: int) -> AsyncIterator[LeaderboardReservationsRow]:
274        result = await self._conn.stream(sqlalchemy.text(LEADERBOARD_RESERVATIONS), {"p1": limit})
275        async for row in result:
276            yield LeaderboardReservationsRow(
277                username=row[0],
278                reservation_count=row[1],
279            )
280
281    async def update_user_email(self, arg: UpdateUserEmailParams) -> Optional[UpdateUserEmailRow]:
282        row = (await self._conn.execute(sqlalchemy.text(UPDATE_USER_EMAIL), {"p1": arg.user_id, "p2": arg.email})).first()
283        if row is None:
284            return None
285        return UpdateUserEmailRow(
286            user_id=row[0],
287            username=row[1],
288            email=row[2],
289            role=row[3],
290            created_at=row[4],
291        )
292
293    async def update_user_password(self, arg: UpdateUserPasswordParams) -> Optional[UpdateUserPasswordRow]:
294        row = (await self._conn.execute(sqlalchemy.text(UPDATE_USER_PASSWORD), {"p1": arg.user_id, "p2": arg.pw_hash})).first()
295        if row is None:
296            return None
297        return UpdateUserPasswordRow(
298            user_id=row[0],
299            username=row[1],
300            email=row[2],
301            role=row[3],
302            created_at=row[4],
303        )
AsyncQuerier(conn: sqlalchemy.ext.asyncio.engine.AsyncConnection)
188    def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection):
189        self._conn = conn
async def create_user( self, arg: CreateUserParams) -> CreateUserRow | None:
191    async def create_user(self, arg: CreateUserParams) -> Optional[CreateUserRow]:
192        row = (await self._conn.execute(sqlalchemy.text(CREATE_USER), {
193            "p1": arg.email,
194            "p2": arg.username,
195            "p3": arg.pw_hash,
196            "p4": arg.role,
197        })).first()
198        if row is None:
199            return None
200        return CreateUserRow(
201            user_id=row[0],
202            username=row[1],
203            email=row[2],
204            role=row[3],
205            created_at=row[4],
206        )
async def delete_user(self, *, user_id: int) -> DeleteUserRow | None:
208    async def delete_user(self, *, user_id: int) -> Optional[DeleteUserRow]:
209        row = (await self._conn.execute(sqlalchemy.text(DELETE_USER), {"p1": user_id})).first()
210        if row is None:
211            return None
212        return DeleteUserRow(
213            user_id=row[0],
214            username=row[1],
215            email=row[2],
216            role=row[3],
217            created_at=row[4],
218        )
async def get_user(self, *, user_id: int) -> GetUserRow | None:
220    async def get_user(self, *, user_id: int) -> Optional[GetUserRow]:
221        row = (await self._conn.execute(sqlalchemy.text(GET_USER), {"p1": user_id})).first()
222        if row is None:
223            return None
224        return GetUserRow(
225            user_id=row[0],
226            username=row[1],
227            email=row[2],
228            role=row[3],
229            created_at=row[4],
230        )
async def get_user_id(self, *, username: str) -> GetUserIdRow | None:
232    async def get_user_id(self, *, username: str) -> Optional[GetUserIdRow]:
233        row = (await self._conn.execute(sqlalchemy.text(GET_USER_ID), {"p1": username})).first()
234        if row is None:
235            return None
236        return GetUserIdRow(
237            user_id=row[0],
238            role=row[1],
239        )
async def get_user_login(self, *, email: str) -> GetUserLoginRow | None:
241    async def get_user_login(self, *, email: str) -> Optional[GetUserLoginRow]:
242        row = (await self._conn.execute(sqlalchemy.text(GET_USER_LOGIN), {"p1": email})).first()
243        if row is None:
244            return None
245        return GetUserLoginRow(
246            user_id=row[0],
247            username=row[1],
248            email=row[2],
249            pw_hash=row[3],
250            role=row[4],
251        )
async def get_users(self) -> AsyncIterator[GetUsersRow]:
253    async def get_users(self) -> AsyncIterator[GetUsersRow]:
254        result = await self._conn.stream(sqlalchemy.text(GET_USERS))
255        async for row in result:
256            yield GetUsersRow(
257                user_id=row[0],
258                username=row[1],
259                email=row[2],
260                role=row[3],
261                created_at=row[4],
262                last_login=row[5],
263            )
async def leaderboard_carbon_dioxide( self, *, limit: int) -> AsyncIterator[LeaderboardCarbonDioxideRow]:
265    async def leaderboard_carbon_dioxide(self, *, limit: int) -> AsyncIterator[LeaderboardCarbonDioxideRow]:
266        result = await self._conn.stream(sqlalchemy.text(LEADERBOARD_CARBON_DIOXIDE), {"p1": limit})
267        async for row in result:
268            yield LeaderboardCarbonDioxideRow(
269                username=row[0],
270                total_carbon_dioxide=row[1],
271            )
async def leaderboard_reservations( self, *, limit: int) -> AsyncIterator[LeaderboardReservationsRow]:
273    async def leaderboard_reservations(self, *, limit: int) -> AsyncIterator[LeaderboardReservationsRow]:
274        result = await self._conn.stream(sqlalchemy.text(LEADERBOARD_RESERVATIONS), {"p1": limit})
275        async for row in result:
276            yield LeaderboardReservationsRow(
277                username=row[0],
278                reservation_count=row[1],
279            )
async def update_user_email( self, arg: UpdateUserEmailParams) -> UpdateUserEmailRow | None:
281    async def update_user_email(self, arg: UpdateUserEmailParams) -> Optional[UpdateUserEmailRow]:
282        row = (await self._conn.execute(sqlalchemy.text(UPDATE_USER_EMAIL), {"p1": arg.user_id, "p2": arg.email})).first()
283        if row is None:
284            return None
285        return UpdateUserEmailRow(
286            user_id=row[0],
287            username=row[1],
288            email=row[2],
289            role=row[3],
290            created_at=row[4],
291        )
async def update_user_password( self, arg: UpdateUserPasswordParams) -> UpdateUserPasswordRow | None:
293    async def update_user_password(self, arg: UpdateUserPasswordParams) -> Optional[UpdateUserPasswordRow]:
294        row = (await self._conn.execute(sqlalchemy.text(UPDATE_USER_PASSWORD), {"p1": arg.user_id, "p2": arg.pw_hash})).first()
295        if row is None:
296            return None
297        return UpdateUserPasswordRow(
298            user_id=row[0],
299            username=row[1],
300            email=row[2],
301            role=row[3],
302            created_at=row[4],
303        )