API Reference¶
Database Constants¶
Core Constants¶
FrameWorkType
¶
OrmType
¶
WriterClassType
¶
Bases: Enum
Enum for writer class types.
Source code in src/supabase_pydantic/core/constants.py
Utility Constants¶
AppConfig
¶
Bases: TypedDict
Configuration for the Supabase Pydantic tool.
Source code in src/supabase_pydantic/utils/constants.py
Database Models¶
ColumnInfo
dataclass
¶
Bases: AsDictParent
Column information.
Source code in src/supabase_pydantic/db/models.py
has_default
property
¶
Check if the column has a default value.
is_generated
property
¶
Check if the column is auto-generated (identity or serial).
__str__()
¶
is_user_defined_type()
¶
nullable()
¶
orm_datatype(orm_type=OrmType.PYDANTIC)
¶
Get the datatype for a column.
Source code in src/supabase_pydantic/db/models.py
orm_imports(orm_type=OrmType.PYDANTIC)
¶
Get the unique import statements for a column.
Source code in src/supabase_pydantic/db/models.py
ConstraintInfo
dataclass
¶
Bases: AsDictParent
Source code in src/supabase_pydantic/db/models.py
__str__()
¶
DatabaseConnectionParams
¶
Bases: BaseModel
Base model for database connection parameters.
Source code in src/supabase_pydantic/db/models.py
DirectConnectionParams
¶
Bases: DatabaseConnectionParams
Connection parameters for direct database connection.
Source code in src/supabase_pydantic/db/models.py
MySQLConnectionParams
¶
Bases: BaseModel
MySQL connection parameters.
Source code in src/supabase_pydantic/db/models.py
is_valid()
¶
Check if parameters are valid for connection.
to_dict()
¶
Convert to dictionary, excluding None values.
Source code in src/supabase_pydantic/db/models.py
validate_port(v)
¶
Validate that port is a valid integer.
Source code in src/supabase_pydantic/db/models.py
PostgresConnectionParams
¶
Bases: BaseModel
Connection parameters for PostgreSQL database.
Source code in src/supabase_pydantic/db/models.py
is_valid()
¶
Check if parameters are valid for connection.
Source code in src/supabase_pydantic/db/models.py
to_dict()
¶
Convert to dictionary, excluding None values.
Source code in src/supabase_pydantic/db/models.py
validate_db_url(v)
¶
Validate db_url format.
Source code in src/supabase_pydantic/db/models.py
validate_port(v)
¶
Validate port is numeric.
Source code in src/supabase_pydantic/db/models.py
TableInfo
dataclass
¶
Bases: AsDictParent
Source code in src/supabase_pydantic/db/models.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 |
|
__str__()
¶
add_column(column)
¶
add_constraint(constraint)
¶
add_foreign_key(fk)
¶
aliasing_in_columns()
¶
get_primary_columns(sort_results=False)
¶
get_secondary_columns(sort_results=False)
¶
has_unique_constraint()
¶
primary_is_composite()
¶
primary_key()
¶
Get the primary key for a table.
Source code in src/supabase_pydantic/db/models.py
sort_and_separate_columns(separate_nullable=False, separate_primary_key=False)
¶
Sort and combine columns based on is_nullable attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
separate_nullable
|
bool
|
Whether to separate nullable and non-nullable columns. |
False
|
separate_primary_key
|
bool
|
Whether to separate primary key and secondary columns. |
False
|
Returns:
Type | Description |
---|---|
SortedColumns
|
A dictionary with keys, nullable, non_nullable, and remaining as keys |
SortedColumns
|
and lists of ColumnInfo objects as values. |
Source code in src/supabase_pydantic/db/models.py
table_dependencies()
¶
URLConnectionParams
¶
Bases: DatabaseConnectionParams
Connection parameters for URL-based database connection.
Source code in src/supabase_pydantic/db/models.py
UserEnumType
dataclass
¶
Bases: AsDictParent
Source code in src/supabase_pydantic/db/models.py
matches_type_name(type_name)
¶
Check if a given type name matches this enum type, handling PostgreSQL array naming conventions.
Source code in src/supabase_pydantic/db/models.py
Core Models¶
EnumInfo
dataclass
¶
Source code in src/supabase_pydantic/core/models.py
python_class_name()
¶
Converts DB enum name to PascalCase for Python class, prefixed by schema.
Handles various input formats: - snake_case: 'order_status' -> 'OrderStatusEnum' - camelCase: 'thirdType' -> 'ThirdTypeEnum' - PascalCase: 'FourthType' -> 'FourthTypeEnum' - mixed: 'Fifth_Type' -> 'FifthTypeEnum' - with leading underscore: '_first_type' -> 'FirstTypeEnum'
Final class name is prefixed by schema: 'public.order_status' -> 'PublicOrderStatusEnum'
Source code in src/supabase_pydantic/core/models.py
python_member_name(value)
¶
Converts enum value to a valid Python identifier.
e.g., 'pending_new' -> 'pending_new'
Writers¶
Serialization¶
AsDictParent
dataclass
¶
Source code in src/supabase_pydantic/utils/serialization.py
CustomJsonEncoder
¶
Bases: JSONEncoder
Custom JSON encoder for encoding decimal and datetime.
Source code in src/supabase_pydantic/utils/serialization.py
default(o)
¶
Encode decimal and datetime objects.