Skip to content

woparry/librarian

 
 

Repository files navigation

README FIRST

Requires some flavour of Linux and Python >= 2.7. Windows users will have to figure out how it works themselves and edit the code to suit.

Also requires the python packages:
isbnlib - For ISBN lookup
zbar
copy
pygtk >= 2.0
gtk >= 2.0
MySQLdb - For MySQl database or
sqlite3  - For sqlite database
reportlab - For PDF report generation
qrencode - For QR code generation
usb - For using a "real" scanner. So far it is hard coded for a Wasp USB scanner.

Some of these can be installed by running:

pip install -r requirements.txt

Get the code with:

git clone https://github.com/EvansMike/librarian.git

Install with: (On a Fedora system) using sudo probably.

pip install biblio.webquery # NB. Not required for latest code.
yum install zbar-pygtk pygtk MySQL-python # If you're using Fedora

python setup.py install

I wanted to catalog all my books using their barcodes as input and track who borrows my books. That’s all. I looked online for a program that would do just that and couldn’t find any that supported barcode input. The idea of typing in book details didn’t appeal, so wrote this.

This is a simple application to catalogue your library using the ISBN barcode and the zbarcam application with an ordinary webcam. The scan triggers a lookup on the database and the book details are downloaded then committed to the local database.

It uses MySQL or sqlite. The database config file is created if none exists.

Use database.schema.sql, after creating the database, to populate the database with the required tables:

mysql -p books < database.schema.sql

You have to create the database first using your favourite method/tool. The database name (books in the example above) can be anything as long as the config file matches. If the config file contains a password so take care to make it secure from prying eyes.

Can also use sqlite. Edit db_conf.cfg to use whatever database you like. Sqlite is easier to set up but not so useful if you want to access the data from multiple computers.

QR Codes

Every time you scan a book a QRcode can be generated. You may not want this behaviour. BY default the behaviour is turned off in the config file. It seemed like a good idea at the time but I admit to never have used the QRcodes for anything. :)

Older books without bar codes can be manually input via the Query/Edit book window. It’s a bit of a pain though if you have lots of books.

DB Notes

To get a list of borrowed books from mysql:

SELECT o_date, title, author, borrowers.name
  FROM borrows, borrowers, books
  WHERE borrows.borrower = borrowers.id
  AND books.id = borrows.book
  AND borrows.i_date IS NULL;

The sqlite2 database file is created from the database.schema.sql file with:

./mysql2sqlite3 --no-data  -p books | sqlite3 database_schema.db

Setting user database password stuff is up to you for the moment. I will add a GUI. NOTE: Passwords are stored as plain text in the config file. On first run a default .db_config.cnf file is written in your home directory, note that this is a hidden dot-file. This must edited with the details of your database plus any other preferences.

To create the tables you will need the books_schema.sql file from the sources. After creating the database run: mysql ←p> books < books_schema.sql to create the tables. The -p is required if your DB is password protected. Obviously you can call the DB anything you like, it doesn’t have to be books, as long as the .db_config.cfg file contains matching details.

To get who borrowed what and for how long:

  SELECT title, name, DATEDIFF(i_date,o_date) AS days
      FROM borrows, borrowers, books
      WHERE borrows.borrower=borrowers.id
      AND books.id=borrows.book;

Windows Users

Apologies to MS Windows, and Mac users, I don’t use MS Windows or a Mac myself so I have no way to develop or test code other than on Linux. You will have to adapt the code to suit.

Stuff that need fixing for MS Windows include zbarcam code in guiscan.py, database connections to anything other than MySQl and sqlite3 is also not currently supported.

About

A book cataloging utility that uses a webcam to scan the ISBN number to input book details. Now with USB scanner ability!

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TeX 36.1%
  • Python 31.6%
  • HTML 21.9%
  • JavaScript 3.8%
  • CSS 3.3%
  • TSQL 1.5%
  • Other 1.8%