First, you need to connect to the database using a DATABASE_URI
Now, we need to start work on the models
We will need 2 models, a User model and a Books model
The User should contain the following , an id(compulsory in a table0, User_ID, Name ,Password, Admin(Boolean value)
The Books model should contain the following , an id, bookid, book name,book_ author, book_available (boolean), user_borrowed_id ( user id of the student who borrowed the book)
Let's help you out a little!
class User(db.Model):
id=db.Column(db.Integer,primary_key=True)
user_id=db.Column(db.String(50),unique=True)
name=db.Column(db.String(50))
password=db.Column(db.String(80))
admin=db.Column(db.Boolean)
class Books(db.Model):
id=db.Column(db.Integer,primary_key=True)
book_name=db.Column(db.String(50))
book_author=db.Column(db.String(50))
book_id=db.Column(db.String(50),unique=True)
book_available=db.Column(db.Boolean)
userborrowedid=db.Column(db.Integer)
Can't get easier than this, let's get cracking!
All you need to this set up the DB on your local machine!
Hey there, let's start working on the database
First, you need to connect to the database using a DATABASE_URI Now, we need to start work on the models We will need 2 models, a User model and a Books model
The User should contain the following , an id(compulsory in a table0, User_ID, Name ,Password, Admin(Boolean value) The Books model should contain the following , an id, bookid, book name,book_ author, book_available (boolean), user_borrowed_id ( user id of the student who borrowed the book)
Let's help you out a little! class User(db.Model): id=db.Column(db.Integer,primary_key=True) user_id=db.Column(db.String(50),unique=True) name=db.Column(db.String(50)) password=db.Column(db.String(80)) admin=db.Column(db.Boolean)
class Books(db.Model): id=db.Column(db.Integer,primary_key=True) book_name=db.Column(db.String(50)) book_author=db.Column(db.String(50)) book_id=db.Column(db.String(50),unique=True) book_available=db.Column(db.Boolean) userborrowedid=db.Column(db.Integer)
Can't get easier than this, let's get cracking! All you need to this set up the DB on your local machine!