internal.queries.seller
1# Code generated by sqlc. DO NOT EDIT. 2# versions: 3# sqlc v1.30.0 4# source: seller.sql 5import datetime 6import pydantic 7from typing import AsyncIterator, Optional 8 9import sqlalchemy 10import sqlalchemy.ext.asyncio 11 12from internal.queries import models 13 14 15CREATE_SELLER = """-- name: create_seller \\:one 16INSERT INTO sellers (user_id, seller_name, address_line1, address_line2, city, post_code, region, country, latitude, longitude) 17VALUES (:p1, :p2, :p3, :p4, :p5, :p6, :p7, :p8, :p9, :p10) 18RETURNING user_id, seller_name, verified_by, verification_date, address_line1, address_line2, city, post_code, region, country, latitude, longitude 19""" 20 21 22class CreateSellerParams(pydantic.BaseModel): 23 user_id: int 24 seller_name: str 25 address_line1: str 26 address_line2: Optional[str] 27 city: str 28 post_code: str 29 region: Optional[str] 30 country: str 31 latitude: Optional[float] 32 longitude: Optional[float] 33 34 35GET_SELLER = """-- name: get_seller \\:one 36SELECT u.user_id, u.username, u.email, s.seller_name, s.address_line1, s.address_line2, s.city, s.post_code, s.region, s.country, s.verified_by, s.verification_date, u.last_login, u.created_at, s.latitude, s.longitude 37FROM sellers s 38INNER JOIN users u ON s.user_id=u.user_id 39WHERE u.user_id=:p1 40LIMIT 1 41""" 42 43 44class GetSellerRow(pydantic.BaseModel): 45 user_id: int 46 username: str 47 email: str 48 seller_name: str 49 address_line1: str 50 address_line2: Optional[str] 51 city: str 52 post_code: str 53 region: Optional[str] 54 country: str 55 verified_by: Optional[int] 56 verification_date: Optional[datetime.datetime] 57 last_login: datetime.datetime 58 created_at: datetime.datetime 59 latitude: Optional[float] 60 longitude: Optional[float] 61 62 63GET_SELLER_BY_LOCATION = """-- name: get_seller_by_location \\:many 64SELECT u.user_id, u.username, u.email, s.seller_name, s.address_line1, s.address_line2, s.city, s.post_code, s.region, s.country, s.verified_by, s.verification_date, u.last_login, u.created_at, s.latitude, s.longitude 65FROM sellers s 66INNER JOIN users u ON s.user_id=u.user_id 67WHERE s.latitude IS NOT NULL AND s.longitude IS NOT NULL AND s.latitude < :p1 AND s.latitude > :p2 AND s.longitude < :p3 AND s.longitude > :p4 68""" 69 70 71class GetSellerByLocationParams(pydantic.BaseModel): 72 lat_max: Optional[float] 73 lat_min: Optional[float] 74 lon_max: Optional[float] 75 lon_min: Optional[float] 76 77 78class GetSellerByLocationRow(pydantic.BaseModel): 79 user_id: int 80 username: str 81 email: str 82 seller_name: str 83 address_line1: str 84 address_line2: Optional[str] 85 city: str 86 post_code: str 87 region: Optional[str] 88 country: str 89 verified_by: Optional[int] 90 verification_date: Optional[datetime.datetime] 91 last_login: datetime.datetime 92 created_at: datetime.datetime 93 latitude: Optional[float] 94 longitude: Optional[float] 95 96 97GET_SELLERS = """-- name: get_sellers \\:many 98SELECT u.user_id, u.username, u.email, s.seller_name, s.address_line1, s.address_line2, s.city, s.post_code, s.region, s.country, s.verified_by, s.verification_date, u.last_login, u.created_at, s.latitude, s.longitude 99FROM sellers s 100INNER JOIN users u ON s.user_id=u.user_id 101""" 102 103 104class GetSellersRow(pydantic.BaseModel): 105 user_id: int 106 username: str 107 email: str 108 seller_name: str 109 address_line1: str 110 address_line2: Optional[str] 111 city: str 112 post_code: str 113 region: Optional[str] 114 country: str 115 verified_by: Optional[int] 116 verification_date: Optional[datetime.datetime] 117 last_login: datetime.datetime 118 created_at: datetime.datetime 119 latitude: Optional[float] 120 longitude: Optional[float] 121 122 123UNVERIFY_SELLER = """-- name: unverify_seller \\:one 124UPDATE sellers 125SET verified_by = NULL, verification_date = NULL 126WHERE user_id = :p1 127RETURNING user_id, seller_name, verified_by, verification_date, address_line1, address_line2, city, post_code, region, country, latitude, longitude 128""" 129 130 131UPDATE_SELLER = """-- name: update_seller \\:one 132UPDATE sellers 133SET seller_name = :p2, address_line1 = :p3, address_line2 = :p4, city = :p5, post_code = :p6, region = :p7, country = :p8, latitude = :p9, longitude = :p10 134WHERE user_id = :p1 135RETURNING user_id, seller_name, verified_by, verification_date, address_line1, address_line2, city, post_code, region, country, latitude, longitude 136""" 137 138 139class UpdateSellerParams(pydantic.BaseModel): 140 user_id: int 141 seller_name: str 142 address_line1: str 143 address_line2: Optional[str] 144 city: str 145 post_code: str 146 region: Optional[str] 147 country: str 148 latitude: Optional[float] 149 longitude: Optional[float] 150 151 152VERIFY_SELLER = """-- name: verify_seller \\:one 153UPDATE sellers 154SET verified_by = :p2, verification_date = NOW() 155WHERE user_id = :p1 156RETURNING user_id, seller_name, verified_by, verification_date, address_line1, address_line2, city, post_code, region, country, latitude, longitude 157""" 158 159 160class VerifySellerParams(pydantic.BaseModel): 161 user_id: int 162 verified_by: Optional[int] 163 164 165class AsyncQuerier: 166 def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection): 167 self._conn = conn 168 169 async def create_seller(self, arg: CreateSellerParams) -> Optional[models.Seller]: 170 row = (await self._conn.execute(sqlalchemy.text(CREATE_SELLER), { 171 "p1": arg.user_id, 172 "p2": arg.seller_name, 173 "p3": arg.address_line1, 174 "p4": arg.address_line2, 175 "p5": arg.city, 176 "p6": arg.post_code, 177 "p7": arg.region, 178 "p8": arg.country, 179 "p9": arg.latitude, 180 "p10": arg.longitude, 181 })).first() 182 if row is None: 183 return None 184 return models.Seller( 185 user_id=row[0], 186 seller_name=row[1], 187 verified_by=row[2], 188 verification_date=row[3], 189 address_line1=row[4], 190 address_line2=row[5], 191 city=row[6], 192 post_code=row[7], 193 region=row[8], 194 country=row[9], 195 latitude=row[10], 196 longitude=row[11], 197 ) 198 199 async def get_seller(self, *, user_id: int) -> Optional[GetSellerRow]: 200 row = (await self._conn.execute(sqlalchemy.text(GET_SELLER), {"p1": user_id})).first() 201 if row is None: 202 return None 203 return GetSellerRow( 204 user_id=row[0], 205 username=row[1], 206 email=row[2], 207 seller_name=row[3], 208 address_line1=row[4], 209 address_line2=row[5], 210 city=row[6], 211 post_code=row[7], 212 region=row[8], 213 country=row[9], 214 verified_by=row[10], 215 verification_date=row[11], 216 last_login=row[12], 217 created_at=row[13], 218 latitude=row[14], 219 longitude=row[15], 220 ) 221 222 async def get_seller_by_location(self, arg: GetSellerByLocationParams) -> AsyncIterator[GetSellerByLocationRow]: 223 result = await self._conn.stream(sqlalchemy.text(GET_SELLER_BY_LOCATION), { 224 "p1": arg.lat_max, 225 "p2": arg.lat_min, 226 "p3": arg.lon_max, 227 "p4": arg.lon_min, 228 }) 229 async for row in result: 230 yield GetSellerByLocationRow( 231 user_id=row[0], 232 username=row[1], 233 email=row[2], 234 seller_name=row[3], 235 address_line1=row[4], 236 address_line2=row[5], 237 city=row[6], 238 post_code=row[7], 239 region=row[8], 240 country=row[9], 241 verified_by=row[10], 242 verification_date=row[11], 243 last_login=row[12], 244 created_at=row[13], 245 latitude=row[14], 246 longitude=row[15], 247 ) 248 249 async def get_sellers(self) -> AsyncIterator[GetSellersRow]: 250 result = await self._conn.stream(sqlalchemy.text(GET_SELLERS)) 251 async for row in result: 252 yield GetSellersRow( 253 user_id=row[0], 254 username=row[1], 255 email=row[2], 256 seller_name=row[3], 257 address_line1=row[4], 258 address_line2=row[5], 259 city=row[6], 260 post_code=row[7], 261 region=row[8], 262 country=row[9], 263 verified_by=row[10], 264 verification_date=row[11], 265 last_login=row[12], 266 created_at=row[13], 267 latitude=row[14], 268 longitude=row[15], 269 ) 270 271 async def unverify_seller(self, *, user_id: int) -> Optional[models.Seller]: 272 row = (await self._conn.execute(sqlalchemy.text(UNVERIFY_SELLER), {"p1": user_id})).first() 273 if row is None: 274 return None 275 return models.Seller( 276 user_id=row[0], 277 seller_name=row[1], 278 verified_by=row[2], 279 verification_date=row[3], 280 address_line1=row[4], 281 address_line2=row[5], 282 city=row[6], 283 post_code=row[7], 284 region=row[8], 285 country=row[9], 286 latitude=row[10], 287 longitude=row[11], 288 ) 289 290 async def update_seller(self, arg: UpdateSellerParams) -> Optional[models.Seller]: 291 row = (await self._conn.execute(sqlalchemy.text(UPDATE_SELLER), { 292 "p1": arg.user_id, 293 "p2": arg.seller_name, 294 "p3": arg.address_line1, 295 "p4": arg.address_line2, 296 "p5": arg.city, 297 "p6": arg.post_code, 298 "p7": arg.region, 299 "p8": arg.country, 300 "p9": arg.latitude, 301 "p10": arg.longitude, 302 })).first() 303 if row is None: 304 return None 305 return models.Seller( 306 user_id=row[0], 307 seller_name=row[1], 308 verified_by=row[2], 309 verification_date=row[3], 310 address_line1=row[4], 311 address_line2=row[5], 312 city=row[6], 313 post_code=row[7], 314 region=row[8], 315 country=row[9], 316 latitude=row[10], 317 longitude=row[11], 318 ) 319 320 async def verify_seller(self, arg: VerifySellerParams) -> Optional[models.Seller]: 321 row = (await self._conn.execute(sqlalchemy.text(VERIFY_SELLER), {"p1": arg.user_id, "p2": arg.verified_by})).first() 322 if row is None: 323 return None 324 return models.Seller( 325 user_id=row[0], 326 seller_name=row[1], 327 verified_by=row[2], 328 verification_date=row[3], 329 address_line1=row[4], 330 address_line2=row[5], 331 city=row[6], 332 post_code=row[7], 333 region=row[8], 334 country=row[9], 335 latitude=row[10], 336 longitude=row[11], 337 )
CREATE_SELLER =
'-- name: create_seller \\:one\nINSERT INTO sellers (user_id, seller_name, address_line1, address_line2, city, post_code, region, country, latitude, longitude)\nVALUES (:p1, :p2, :p3, :p4, :p5, :p6, :p7, :p8, :p9, :p10)\nRETURNING user_id, seller_name, verified_by, verification_date, address_line1, address_line2, city, post_code, region, country, latitude, longitude\n'
class
CreateSellerParams(pydantic.main.BaseModel):
23class CreateSellerParams(pydantic.BaseModel): 24 user_id: int 25 seller_name: str 26 address_line1: str 27 address_line2: Optional[str] 28 city: str 29 post_code: str 30 region: Optional[str] 31 country: str 32 latitude: Optional[float] 33 longitude: Optional[float]
!!! 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.
GET_SELLER =
'-- name: get_seller \\:one\nSELECT u.user_id, u.username, u.email, s.seller_name, s.address_line1, s.address_line2, s.city, s.post_code, s.region, s.country, s.verified_by, s.verification_date, u.last_login, u.created_at, s.latitude, s.longitude\nFROM sellers s\nINNER JOIN users u ON s.user_id=u.user_id\nWHERE u.user_id=:p1\nLIMIT 1\n'
class
GetSellerRow(pydantic.main.BaseModel):
45class GetSellerRow(pydantic.BaseModel): 46 user_id: int 47 username: str 48 email: str 49 seller_name: str 50 address_line1: str 51 address_line2: Optional[str] 52 city: str 53 post_code: str 54 region: Optional[str] 55 country: str 56 verified_by: Optional[int] 57 verification_date: Optional[datetime.datetime] 58 last_login: datetime.datetime 59 created_at: datetime.datetime 60 latitude: Optional[float] 61 longitude: Optional[float]
!!! 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.
GET_SELLER_BY_LOCATION =
'-- name: get_seller_by_location \\:many\nSELECT u.user_id, u.username, u.email, s.seller_name, s.address_line1, s.address_line2, s.city, s.post_code, s.region, s.country, s.verified_by, s.verification_date, u.last_login, u.created_at, s.latitude, s.longitude\nFROM sellers s\nINNER JOIN users u ON s.user_id=u.user_id\nWHERE s.latitude IS NOT NULL AND s.longitude IS NOT NULL AND s.latitude < :p1 AND s.latitude > :p2 AND s.longitude < :p3 AND s.longitude > :p4\n'
class
GetSellerByLocationParams(pydantic.main.BaseModel):
72class GetSellerByLocationParams(pydantic.BaseModel): 73 lat_max: Optional[float] 74 lat_min: Optional[float] 75 lon_max: Optional[float] 76 lon_min: Optional[float]
!!! 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
GetSellerByLocationRow(pydantic.main.BaseModel):
79class GetSellerByLocationRow(pydantic.BaseModel): 80 user_id: int 81 username: str 82 email: str 83 seller_name: str 84 address_line1: str 85 address_line2: Optional[str] 86 city: str 87 post_code: str 88 region: Optional[str] 89 country: str 90 verified_by: Optional[int] 91 verification_date: Optional[datetime.datetime] 92 last_login: datetime.datetime 93 created_at: datetime.datetime 94 latitude: Optional[float] 95 longitude: Optional[float]
!!! 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.
GET_SELLERS =
'-- name: get_sellers \\:many\nSELECT u.user_id, u.username, u.email, s.seller_name, s.address_line1, s.address_line2, s.city, s.post_code, s.region, s.country, s.verified_by, s.verification_date, u.last_login, u.created_at, s.latitude, s.longitude\nFROM sellers s\nINNER JOIN users u ON s.user_id=u.user_id\n'
class
GetSellersRow(pydantic.main.BaseModel):
105class GetSellersRow(pydantic.BaseModel): 106 user_id: int 107 username: str 108 email: str 109 seller_name: str 110 address_line1: str 111 address_line2: Optional[str] 112 city: str 113 post_code: str 114 region: Optional[str] 115 country: str 116 verified_by: Optional[int] 117 verification_date: Optional[datetime.datetime] 118 last_login: datetime.datetime 119 created_at: datetime.datetime 120 latitude: Optional[float] 121 longitude: Optional[float]
!!! 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.
UNVERIFY_SELLER =
'-- name: unverify_seller \\:one\nUPDATE sellers\nSET verified_by = NULL, verification_date = NULL\nWHERE user_id = :p1\nRETURNING user_id, seller_name, verified_by, verification_date, address_line1, address_line2, city, post_code, region, country, latitude, longitude\n'
UPDATE_SELLER =
'-- name: update_seller \\:one\nUPDATE sellers\nSET seller_name = :p2, address_line1 = :p3, address_line2 = :p4, city = :p5, post_code = :p6, region = :p7, country = :p8, latitude = :p9, longitude = :p10\nWHERE user_id = :p1\nRETURNING user_id, seller_name, verified_by, verification_date, address_line1, address_line2, city, post_code, region, country, latitude, longitude\n'
class
UpdateSellerParams(pydantic.main.BaseModel):
140class UpdateSellerParams(pydantic.BaseModel): 141 user_id: int 142 seller_name: str 143 address_line1: str 144 address_line2: Optional[str] 145 city: str 146 post_code: str 147 region: Optional[str] 148 country: str 149 latitude: Optional[float] 150 longitude: Optional[float]
!!! 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.
VERIFY_SELLER =
'-- name: verify_seller \\:one\nUPDATE sellers\nSET verified_by = :p2, verification_date = NOW()\nWHERE user_id = :p1\nRETURNING user_id, seller_name, verified_by, verification_date, address_line1, address_line2, city, post_code, region, country, latitude, longitude\n'
class
VerifySellerParams(pydantic.main.BaseModel):
!!! 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:
166class AsyncQuerier: 167 def __init__(self, conn: sqlalchemy.ext.asyncio.AsyncConnection): 168 self._conn = conn 169 170 async def create_seller(self, arg: CreateSellerParams) -> Optional[models.Seller]: 171 row = (await self._conn.execute(sqlalchemy.text(CREATE_SELLER), { 172 "p1": arg.user_id, 173 "p2": arg.seller_name, 174 "p3": arg.address_line1, 175 "p4": arg.address_line2, 176 "p5": arg.city, 177 "p6": arg.post_code, 178 "p7": arg.region, 179 "p8": arg.country, 180 "p9": arg.latitude, 181 "p10": arg.longitude, 182 })).first() 183 if row is None: 184 return None 185 return models.Seller( 186 user_id=row[0], 187 seller_name=row[1], 188 verified_by=row[2], 189 verification_date=row[3], 190 address_line1=row[4], 191 address_line2=row[5], 192 city=row[6], 193 post_code=row[7], 194 region=row[8], 195 country=row[9], 196 latitude=row[10], 197 longitude=row[11], 198 ) 199 200 async def get_seller(self, *, user_id: int) -> Optional[GetSellerRow]: 201 row = (await self._conn.execute(sqlalchemy.text(GET_SELLER), {"p1": user_id})).first() 202 if row is None: 203 return None 204 return GetSellerRow( 205 user_id=row[0], 206 username=row[1], 207 email=row[2], 208 seller_name=row[3], 209 address_line1=row[4], 210 address_line2=row[5], 211 city=row[6], 212 post_code=row[7], 213 region=row[8], 214 country=row[9], 215 verified_by=row[10], 216 verification_date=row[11], 217 last_login=row[12], 218 created_at=row[13], 219 latitude=row[14], 220 longitude=row[15], 221 ) 222 223 async def get_seller_by_location(self, arg: GetSellerByLocationParams) -> AsyncIterator[GetSellerByLocationRow]: 224 result = await self._conn.stream(sqlalchemy.text(GET_SELLER_BY_LOCATION), { 225 "p1": arg.lat_max, 226 "p2": arg.lat_min, 227 "p3": arg.lon_max, 228 "p4": arg.lon_min, 229 }) 230 async for row in result: 231 yield GetSellerByLocationRow( 232 user_id=row[0], 233 username=row[1], 234 email=row[2], 235 seller_name=row[3], 236 address_line1=row[4], 237 address_line2=row[5], 238 city=row[6], 239 post_code=row[7], 240 region=row[8], 241 country=row[9], 242 verified_by=row[10], 243 verification_date=row[11], 244 last_login=row[12], 245 created_at=row[13], 246 latitude=row[14], 247 longitude=row[15], 248 ) 249 250 async def get_sellers(self) -> AsyncIterator[GetSellersRow]: 251 result = await self._conn.stream(sqlalchemy.text(GET_SELLERS)) 252 async for row in result: 253 yield GetSellersRow( 254 user_id=row[0], 255 username=row[1], 256 email=row[2], 257 seller_name=row[3], 258 address_line1=row[4], 259 address_line2=row[5], 260 city=row[6], 261 post_code=row[7], 262 region=row[8], 263 country=row[9], 264 verified_by=row[10], 265 verification_date=row[11], 266 last_login=row[12], 267 created_at=row[13], 268 latitude=row[14], 269 longitude=row[15], 270 ) 271 272 async def unverify_seller(self, *, user_id: int) -> Optional[models.Seller]: 273 row = (await self._conn.execute(sqlalchemy.text(UNVERIFY_SELLER), {"p1": user_id})).first() 274 if row is None: 275 return None 276 return models.Seller( 277 user_id=row[0], 278 seller_name=row[1], 279 verified_by=row[2], 280 verification_date=row[3], 281 address_line1=row[4], 282 address_line2=row[5], 283 city=row[6], 284 post_code=row[7], 285 region=row[8], 286 country=row[9], 287 latitude=row[10], 288 longitude=row[11], 289 ) 290 291 async def update_seller(self, arg: UpdateSellerParams) -> Optional[models.Seller]: 292 row = (await self._conn.execute(sqlalchemy.text(UPDATE_SELLER), { 293 "p1": arg.user_id, 294 "p2": arg.seller_name, 295 "p3": arg.address_line1, 296 "p4": arg.address_line2, 297 "p5": arg.city, 298 "p6": arg.post_code, 299 "p7": arg.region, 300 "p8": arg.country, 301 "p9": arg.latitude, 302 "p10": arg.longitude, 303 })).first() 304 if row is None: 305 return None 306 return models.Seller( 307 user_id=row[0], 308 seller_name=row[1], 309 verified_by=row[2], 310 verification_date=row[3], 311 address_line1=row[4], 312 address_line2=row[5], 313 city=row[6], 314 post_code=row[7], 315 region=row[8], 316 country=row[9], 317 latitude=row[10], 318 longitude=row[11], 319 ) 320 321 async def verify_seller(self, arg: VerifySellerParams) -> Optional[models.Seller]: 322 row = (await self._conn.execute(sqlalchemy.text(VERIFY_SELLER), {"p1": arg.user_id, "p2": arg.verified_by})).first() 323 if row is None: 324 return None 325 return models.Seller( 326 user_id=row[0], 327 seller_name=row[1], 328 verified_by=row[2], 329 verification_date=row[3], 330 address_line1=row[4], 331 address_line2=row[5], 332 city=row[6], 333 post_code=row[7], 334 region=row[8], 335 country=row[9], 336 latitude=row[10], 337 longitude=row[11], 338 )
170 async def create_seller(self, arg: CreateSellerParams) -> Optional[models.Seller]: 171 row = (await self._conn.execute(sqlalchemy.text(CREATE_SELLER), { 172 "p1": arg.user_id, 173 "p2": arg.seller_name, 174 "p3": arg.address_line1, 175 "p4": arg.address_line2, 176 "p5": arg.city, 177 "p6": arg.post_code, 178 "p7": arg.region, 179 "p8": arg.country, 180 "p9": arg.latitude, 181 "p10": arg.longitude, 182 })).first() 183 if row is None: 184 return None 185 return models.Seller( 186 user_id=row[0], 187 seller_name=row[1], 188 verified_by=row[2], 189 verification_date=row[3], 190 address_line1=row[4], 191 address_line2=row[5], 192 city=row[6], 193 post_code=row[7], 194 region=row[8], 195 country=row[9], 196 latitude=row[10], 197 longitude=row[11], 198 )
200 async def get_seller(self, *, user_id: int) -> Optional[GetSellerRow]: 201 row = (await self._conn.execute(sqlalchemy.text(GET_SELLER), {"p1": user_id})).first() 202 if row is None: 203 return None 204 return GetSellerRow( 205 user_id=row[0], 206 username=row[1], 207 email=row[2], 208 seller_name=row[3], 209 address_line1=row[4], 210 address_line2=row[5], 211 city=row[6], 212 post_code=row[7], 213 region=row[8], 214 country=row[9], 215 verified_by=row[10], 216 verification_date=row[11], 217 last_login=row[12], 218 created_at=row[13], 219 latitude=row[14], 220 longitude=row[15], 221 )
async def
get_seller_by_location( self, arg: GetSellerByLocationParams) -> AsyncIterator[GetSellerByLocationRow]:
223 async def get_seller_by_location(self, arg: GetSellerByLocationParams) -> AsyncIterator[GetSellerByLocationRow]: 224 result = await self._conn.stream(sqlalchemy.text(GET_SELLER_BY_LOCATION), { 225 "p1": arg.lat_max, 226 "p2": arg.lat_min, 227 "p3": arg.lon_max, 228 "p4": arg.lon_min, 229 }) 230 async for row in result: 231 yield GetSellerByLocationRow( 232 user_id=row[0], 233 username=row[1], 234 email=row[2], 235 seller_name=row[3], 236 address_line1=row[4], 237 address_line2=row[5], 238 city=row[6], 239 post_code=row[7], 240 region=row[8], 241 country=row[9], 242 verified_by=row[10], 243 verification_date=row[11], 244 last_login=row[12], 245 created_at=row[13], 246 latitude=row[14], 247 longitude=row[15], 248 )
250 async def get_sellers(self) -> AsyncIterator[GetSellersRow]: 251 result = await self._conn.stream(sqlalchemy.text(GET_SELLERS)) 252 async for row in result: 253 yield GetSellersRow( 254 user_id=row[0], 255 username=row[1], 256 email=row[2], 257 seller_name=row[3], 258 address_line1=row[4], 259 address_line2=row[5], 260 city=row[6], 261 post_code=row[7], 262 region=row[8], 263 country=row[9], 264 verified_by=row[10], 265 verification_date=row[11], 266 last_login=row[12], 267 created_at=row[13], 268 latitude=row[14], 269 longitude=row[15], 270 )
272 async def unverify_seller(self, *, user_id: int) -> Optional[models.Seller]: 273 row = (await self._conn.execute(sqlalchemy.text(UNVERIFY_SELLER), {"p1": user_id})).first() 274 if row is None: 275 return None 276 return models.Seller( 277 user_id=row[0], 278 seller_name=row[1], 279 verified_by=row[2], 280 verification_date=row[3], 281 address_line1=row[4], 282 address_line2=row[5], 283 city=row[6], 284 post_code=row[7], 285 region=row[8], 286 country=row[9], 287 latitude=row[10], 288 longitude=row[11], 289 )
291 async def update_seller(self, arg: UpdateSellerParams) -> Optional[models.Seller]: 292 row = (await self._conn.execute(sqlalchemy.text(UPDATE_SELLER), { 293 "p1": arg.user_id, 294 "p2": arg.seller_name, 295 "p3": arg.address_line1, 296 "p4": arg.address_line2, 297 "p5": arg.city, 298 "p6": arg.post_code, 299 "p7": arg.region, 300 "p8": arg.country, 301 "p9": arg.latitude, 302 "p10": arg.longitude, 303 })).first() 304 if row is None: 305 return None 306 return models.Seller( 307 user_id=row[0], 308 seller_name=row[1], 309 verified_by=row[2], 310 verification_date=row[3], 311 address_line1=row[4], 312 address_line2=row[5], 313 city=row[6], 314 post_code=row[7], 315 region=row[8], 316 country=row[9], 317 latitude=row[10], 318 longitude=row[11], 319 )
321 async def verify_seller(self, arg: VerifySellerParams) -> Optional[models.Seller]: 322 row = (await self._conn.execute(sqlalchemy.text(VERIFY_SELLER), {"p1": arg.user_id, "p2": arg.verified_by})).first() 323 if row is None: 324 return None 325 return models.Seller( 326 user_id=row[0], 327 seller_name=row[1], 328 verified_by=row[2], 329 verification_date=row[3], 330 address_line1=row[4], 331 address_line2=row[5], 332 city=row[6], 333 post_code=row[7], 334 region=row[8], 335 country=row[9], 336 latitude=row[10], 337 longitude=row[11], 338 )