Skip to content

Releases: codemation/pydbantic

0.0.36

06 Feb 15:21
d2dbe73
Compare
Choose a tag to compare

What's Changed

  • Added supported sa_type verification & annotation field generators by @codemation in #48

Full Changelog: 0.0.35...0.0.36

0.0.35

06 Feb 12:10
5413e3b
Compare
Choose a tag to compare

What's Changed

  • Improved Field annotations of sqlalchemy_type argument in Default, Unique, PrimaryKey, ModelField by @codemation in #47

Full Changelog: 0.0.34...0.0.35

0.0.34

06 Feb 10:09
984a005
Compare
Choose a tag to compare

What's Changed

  • updated .all, .filter, .select List Type annotations by @codemation in #46

Full Changelog: 0.0.33...0.0.34

0.0.33

06 Feb 09:09
3053c94
Compare
Choose a tag to compare

What's Changed

Full Changelog: 0.0.32...0.0.33

0.0.32

03 Feb 09:56
8a156e2
Compare
Choose a tag to compare

What's Changed

  • fixed relationship_definitions single direction by @codemation in #44

Full Changelog: 0.0.31...0.0.32

0.0.31

02 Feb 19:50
b75b374
Compare
Choose a tag to compare

Full Changelog: 0.0.30...0.0.31

0.0.30

02 Feb 19:13
851676a
Compare
Choose a tag to compare

What's Changed

Full Changelog: 0.0.29...0.0.30

0.0.29

31 Jan 14:30
def391c
Compare
Choose a tag to compare

What's Changed

  • Replace pydantic Field usage with custom Field class which limits kw… by @codemation in #41

Full Changelog: 0.0.28...0.0.29

0.0.28 - Sqlalchemy Type definition, and Relationship / Foreign Key definitions, support for Autoincrement

30 Jan 11:44
7c62052
Compare
Choose a tag to compare

What's Changed

  • Added Support for Autoincrement, ForeignKeys, Relationship, sqlalchemy type within for ModelField, PrimaryKey, Default (#39), Unique fieldsby @codemation in #39
  • New Relationship mapping options
  • Sqlalchemy type definitions

Examples

from uuid import uuid4
from datetime import datetime
from typing import List, Optional, Union
import sqlalchemy
from pydbantic import DataBaseModel, PrimaryKey, Unique, Relationship, ForeignKey

def uuid_str():
    return str(uuid4())

class Department(DataBaseModel):
    department_id: str = PrimaryKey()
    name: str
    company: str
    is_sensitive: bool = False
    positions: List[Optional['Positions']] = []

class Positions(DataBaseModel):
    position_id: str = PrimaryKey()
    name: str
    department: Department = None
    employees: List[Optional['Employee']] = []

class EmployeeInfo(DataBaseModel):
    __tablename__ = "employee_info"
    ssn: Optional[int] = PrimaryKey(sqlalchemy_type=sqlalchemy.Integer, autoincrement=True)
    bio_id: str = Unique(sqlalchemy.String(50), default=uuid_str)
    first_name: str
    last_name: str
    address: str
    address2: Optional[str]
    city: Optional[str]
    zip: Optional[int]
    new: Optional[str]
    employee: Optional['Employee'] = Relationship("Employee", 'bio_id', 'employee_id')

class Employee(DataBaseModel):
    __tablename__ = "employee"
    employee_id: str = PrimaryKey()
    emp_ssn: Optional[int] = ForeignKey(EmployeeInfo, 'ssn')
    employee_info: Optional[EmployeeInfo] = Relationship("EmployeeInfo", 'employee_id', 'bio_id')
    position: List[Optional[Positions]] = []
    salary: float
    is_employed: bool
    date_employed: Optional[str]

def time_now():
    return datetime.now().isoformat()
def get_uuid4():
    return str(uuid4())


class Coordinate(DataBaseModel):
    id: str = PrimaryKey(default=get_uuid4)
    lat_long: tuple
    journeys: List[Optional["Journey"]] = []

class Journey(DataBaseModel):
    trip_id: str = PrimaryKey(default=get_uuid4)
    waypoints: List[Optional[Coordinate]] = []

Full Changelog: 0.0.27...0.0.28

0.0.27

13 Dec 09:55
Compare
Choose a tag to compare

Full Changelog: 0.0.26...0.0.27