omymodels
omymodels copied to clipboard
Complete Type Mapping
I've added the complete types for MySQL and PostgreSQL. Correct pydantic types are now generated.
CREATE TABLE test_table (
id INT NOT NULL AUTO_INCREMENT,
tiny_int_example TINYINT DEFAULT 0,
small_int_example SMALLINT DEFAULT 0,
medium_int_example MEDIUMINT DEFAULT 0,
big_int_example BIGINT DEFAULT 0,
decimal_example DECIMAL(10, 2) DEFAULT 0.00,
float_example FLOAT DEFAULT 0,
double_example DOUBLE DEFAULT 0,
time_example TIME DEFAULT NULL,
start_date datetime DEFAULT NULL,
end_date datetime DEFAULT NULL,
year_example YEAR DEFAULT NULL,
char_example CHAR(100) DEFAULT NULL,
varchar_example VARCHAR(255) DEFAULT NULL,
tiny_text_example TINYTEXT,
text_example TEXT,
medium_text_example MEDIUMTEXT,
long_text_example LONGTEXT,
binary_example BINARY(16) DEFAULT NULL,
varbinary_example VARBINARY(255) DEFAULT NULL,
tiny_blob_example TINYBLOB,
blob_example BLOB,
medium_blob_example MEDIUMBLOB,
long_blob_example LONGBLOB,
json_example JSON DEFAULT NULL,
boolean_example TINYINT(1) DEFAULT 0,
point_example POINT DEFAULT NULL,
line_example LINESTRING DEFAULT NULL,
polygon_example POLYGON DEFAULT NULL,
) ENGINE=InnoDB;
import datetime as datetime
from typing import Any, List, Optional
from pydantic import BaseModel
class TestTable(BaseModel):
id: int
tiny_int_example: Optional[int]
small_int_example: Optional[int] = 0
medium_int_example: Optional[int] = 0
big_int_example: Optional[float] = 0
decimal_example: Optional[float] = 0.00
float_example: Optional[float] = 0
double_example: Optional[float] = 0
time_example: Optional[datetime]
start_date: Optional[datetime]
end_date: Optional[datetime]
year_example: Optional[datetime]
char_example: Optional[str]
varchar_example: Optional[str]
tiny_text_example: Optional[str]
text_example: Optional[str]
medium_text_example: Optional[str]
long_text_example: Optional[str]
binary_example: Optional[bytes]
varbinary_example: Optional[bytes]
tiny_blob_example: Optional[bytes]
blob_example: Optional[bytes]
medium_blob_example: Optional[bytes]
long_blob_example: Optional[bytes]
json_example: Optional[Any]
boolean_example: Optional[int] = 0
point_example: Optional[List[float]]
line_example: Optional[List[List[float]]]
polygon_example: Optional[List[List[List[float]]]]