Archive for July 5, 2020

Python: Library Managment System -P6

Learning : Python, DataBase, SQlite
Subject: Create Simple Library Managment System

This will be the last post of Library Managment System, and we will start another project. So in this last part, we will write a final function to get some statistics & summaries about our Library such as :

  • Number of book in the library
  • Books without classifications
  • Books without Author
  • Books without ISBN
  • Books under each classification
  • Statistics about Authors
  • Statistics about Classifications

so we will add the function name in the Main Menu (in this case will take number 5), here is a screen shot of the menu.

So we will write some SQL commands using (SQlite), we will start with Books statistics and will NOT cover all commands, but all will be in the course code file in the Download page.

#Total Books in the Library
    c.execute ("select count() from books where b_id > 0") 
    books_count = c.fetchone()

 # Books without classifications

    c.execute ("select b_id from b_class where b_class_id > 0") 
    books_no_class = [item[0] for item in c.fetchall()]    

 # Authors without emails

    c.execute ("select count() from authors where a_email='' and a_id > 0") 
    auth_no_email = c.fetchall()

 # Authors without Social Media Account
    c.execute ("select a_id from sma where sma_id > 0") 
    sma_aid = c.fetchall()       
    a_in_sma = lambda sma_aid: [sma_id for each in sma_aid for sma_id in each]
    a_with_sma = list(dict.fromkeys(a_in_sma(sma_aid)))
    print('     Total Authors without Social Media Accounts: ',(auth_count[0] - len(a_with_sma)))  

Here is the run-time for sample data ..

By this point I will stop working on the “Library Managment System“, the goal of this series of articles was to build a Fast, Simple, Personal system. We did NOT cover some important issues like Validations or Exporting the data.

Here are some points we can incluod in Version 02 of the LMS Application.

  1. Validations: We need to make sure the user Entering in right and good format as we expect. [Date format, Emails, ISBN and So-On]

  2. User Deletign: This is very Important, so if the user Deletes a Classification or Books or Authors we MUST do some modifications on other tables in the DataBase. [Very High Priority]

  3. Capitalization: To make sure we capitalize all user inputs like first character in each Names [Books name, Authors .. So-On].

  4. Search: Although we have this option in our Main-Menu, but I will not cover it in this Version due to time consumption.

  5. Date Export: This is an extra option we may have to Export the Data as Excel or DB-Backup file.
  6. Multi Libraries: In family using of the system, we can insert Books of other family members (Father Home Library, Brother or Cousin). So in that case we need a Full set of Functions to manage this part.
  7. .

[ NOTE ]
1. I am using Galaxy Tab and QPython3 App.
2. All the above codes are available in the Download Section/Page under the project name.
3. The application codes, Functions, Menus and other parts of the Application are subject of changes. In case of changes I will mention that.
4. This is a simple personal Library application, so I did not use any validations on Data Entry.

:: Library Managment System ::

Part 1 Part 2 Part 3 Part 4
Part 5 Part 6

To Download my Python code (.py) files Click-Here

Follow me on Twitter..

By: Ali Radwani