DEV Community

loading...
Cover image for Python Library Management Project

Python Library Management Project

rrtutors profile image rrtutors Originally published at rrtutors.com Updated on ・2 min read

Python library management system project with simple and easy code. This python Library system implemented data storage in MySQL Database. This Database contains the different tables to maintain the data about the library. This Library Management project has different features

Features of Library Management System Project

  1. Add Books
  2. Add Member
  3. Update Book
  4. Update Member
  5. Issue Book
  6. Return Book
  7. Search Menu
  8. Report Menu

This LMS project store the data in database, this Project created a MySQL database with name "library"

This Database has 3 tables to store and retrieve the data about the LMS system.

To implement python Library Management project used below modules

MySql Connector : This module is used to connect mysql database to fetch/add data into database

DateTime : To set date and get current date and update the details on the tables

import mysql.connector
from datetime import date
Enter fullscreen mode Exit fullscreen mode

Alt Text

To Add a book we will use this below code

def add_book():
  conn = mysql.connector.connect(
       host='localhost', database='library', user='root', password='')
  cursor = conn.cursor()

  title = raw_input('Enter Book Title :')
  author = raw_input('Enter Book Author : ')
  publisher = raw_input('Enter Book Publisher : ')
  pages = raw_input('Enter Book Pages : ')
  price = raw_input('Enter Book Price : ')
  edition = raw_input('Enter Book Edition : ')
  copies  = int(raw_input('Enter copies : '))
  sql = 'insert into book(title,author,price,pages,publisher,edition,status) values ( "' + \
       title + '","' + author+'",'+price+','+pages+',"'+publisher+'","'+edition+'","available");'
   #sql2 = 'insert into transaction(dot,qty,type) values ("'+str(today)+'",'+qty+',"purchase");'
  #print(sql)
  for _ in range(0,copies):
    cursor.execute(sql)
  conn.close()
  print('\n\nNew Book added successfully')
  wait = raw_input('\n\n\n Press any key to continue....')
Enter fullscreen mode Exit fullscreen mode

Like the above functionality we can add other features like Add Student, Update Book, Update Member, search books, Book reports etc...

Interested to use complete Python library management system code here

Discussion (0)

pic
Editor guide