Coverage for demo_server/database/models.py: 89%

18 statements  

« prev     ^ index     » next       coverage.py v7.10.6, created at 2025-12-05 15:36 +0000

1# Copyright (c) Microsoft Corporation. 

2# Licensed under the MIT License. 

3 

4# The examples in this file come from the Flask-SQLAlchemy documentation 

5# For more information take a look at: 

6# http://flask-sqlalchemy.pocoo.org/2.1/quickstart/#simple-relationships 

7import os,binascii 1a

8 

9from datetime import datetime 1a

10from flask_sqlalchemy import SQLAlchemy 1a

11 

12db = SQLAlchemy() 1a

13 

14 

15class Post(db.Model): 1a

16 id = db.Column(db.Integer, primary_key=True) 1a

17 body = db.Column(db.Text) 1a

18 checksum = db.Column(db.Text) 1a

19 

20 def __init__(self, body): 1a

21 self.body = body 1bcdefghijklmnop

22 self.checksum = binascii.b2a_hex(os.urandom(100))[:5] 1bcdefghijklmnop

23 

24class Category(db.Model): 1a

25 categoryId = db.Column(db.Integer, primary_key=True) 1a

26 name = db.Column(db.String(50)) 1a

27 

28 def __init__(self, name): 1a

29 self.name = name 

30 

31 def __repr__(self): 1a

32 return '<Category %r>' % self.name