Skip to content

Commit e898493

Browse files
airibarnetiangolo
andauthored
♻️ Simplify DB base class declaration (fastapi#117)
* Simplify DB base class declaration * ♻️ Remove object inheritance Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
1 parent e364044 commit e898493

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
from sqlalchemy.ext.declarative import declarative_base, declared_attr
1+
from sqlalchemy.ext.declarative import as_declarative, declared_attr
22

33

4-
class CustomBase(object):
4+
@as_declarative()
5+
class Base:
56
# Generate __tablename__ automatically
67
@declared_attr
78
def __tablename__(cls):
89
return cls.__name__.lower()
9-
10-
11-
Base = declarative_base(cls=CustomBase)

0 commit comments

Comments
 (0)