-
Notifications
You must be signed in to change notification settings - Fork 1
/
create_db.py
35 lines (25 loc) · 709 Bytes
/
create_db.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from sqlalchemy import Column, String, Integer, Text
from app import db
import os
class Book(db.Model):
__tablename__ = "book"
id = Column(Integer, primary_key=True)
isbn = Column(String(13))
author = Column(String(255))
title = Column(Text)
try:
os.remove("sample.db")
except:
pass
db.create_all()
book1 = Book()
book1.isbn = "1795234318"
book1.author = "Anthony Brun"
book1.title = "Python Programming: A Step By Step Guide From Beginner To Expert (Beginner, Intermediate & Advanced)"
book2 = Book()
book2.isbn = "9781617294433"
book2.author = "Francois Chollet"
book2.title = "Deep Learning with Python"
db.session.add(book1)
db.session.add(book2)
db.session.commit()