Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf8 -*-
- import RPi.GPIO as GPIO
- import MFRC522
- import MySQLdb as mdb
- con = mdb.connect('IP', 'USER', 'PASS', 'DATABASE')
- cur = con.cursor()
- def user_display(uid):
- results = cur.execute("SELECT * FROM staff WHERE uid = "+uid+"")
- return results
- MIFAREReader = MFRC522.MFRC522()
- try:
- while True:
- (status, TagType) = MIFAREReader.MFRC522_Request(MIFAREReader.PICC_REQIDL)
- if status == MIFAREReader.MI_OK:
- print "Card detected"
- (status, uid) = MIFAREReader.MFRC522_Anticoll()
- if status == MIFAREReader.MI_OK:
- UIDcode = str(uid[0]) + str(uid[1]) + str(uid[2]) + str(uid[3])
- print user_display(UIDcode)
- except KeyboardInterrupt:
- GPIO.cleanup()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement