introduce docs -> models section mostly finished
This commit is contained in:
22
docs_src/models/docs004.py
Normal file
22
docs_src/models/docs004.py
Normal file
@ -0,0 +1,22 @@
|
||||
import databases
|
||||
import sqlalchemy
|
||||
|
||||
import orm
|
||||
|
||||
database = databases.Database("sqlite:///db.sqlite")
|
||||
metadata = sqlalchemy.MetaData()
|
||||
|
||||
|
||||
class Course(orm.Model):
|
||||
__database__ = database
|
||||
__metadata__ = metadata
|
||||
|
||||
id = orm.Integer(primary_key=True)
|
||||
name = orm.String(length=100)
|
||||
completed = orm.Boolean(default=False)
|
||||
|
||||
print(Course.__table__.columns)
|
||||
"""
|
||||
Will produce:
|
||||
['courses.id', 'courses.name', 'courses.completed']
|
||||
"""
|
||||
Reference in New Issue
Block a user