Advertisement
Guest User

Untitled

a guest
May 20th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. import mysql.connector
  2.  
  3. #all the tables we did in our data base in order to do the checks.
  4.  
  5. #connect to the database
  6. DB = mysql.connector.connect(user='ADMIN', password='ADMIN', host='localhost', database='pym')
  7. sql = DB.cursor()
  8.  
  9. # msg table (the messaging table)
  10. msg = "CREATE TABLE pym.msg(MsgID INT NOT NULL AUTO_INCREMENT, surce TEXT NOT NULL, dest TEXT NOT NULL, date TEXT, content TEXT, PRIMARY KEY ( MsgID )); "
  11. sql.execute(msg)
  12.  
  13.  
  14. # uesers table
  15. msg = "CREATE TABLE pym.users(UserID INT NOT NULL AUTO_INCREMENT, UserName TEXT NOT NULL, UserPassword TEXT NOT NULL, Premition ENUM('Admin', 'Standard','','') NOT NULL, PRIMARY KEY ( UserID ));"
  16. sql.execute(msg)
  17.  
  18. # devices table
  19. msg = "CREATE TABLE pym.device(DEV_ID INT NOT NULL AUTO_INCREMENT, DEV_Type ENUM('IR_sensor', 'Door_sensor','Relay_modul','Temperature_sensor','Tilt_sensor'), DEV_location TEXT NOT NULL, DEV_options ENUM('active', 'passive','','') NOT NULL, DEV_stat TEXT NOT NULL, PRIMARY KEY ( DEV_ID ));"
  20. sql.execute(msg)
  21.  
  22. DB.commit()
  23. sql.close()
  24. DB.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement