sourav8256

Untitled

Oct 1st, 2019
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.37 KB | None | 0 0
  1. # Check Examples
  2.  
  3. #python 2.7.15
  4.  
  5. print "Hello, Dcoder!"
  6.  
  7.  
  8.  
  9.  
  10. import mysql.connector
  11. from datetime import datetime
  12.  
  13. mydb = mysql.connector.connect(
  14.   host="localhost",
  15.   user="yourusername",
  16.   passwd="yourpassword",
  17.   database="mydatabase"
  18. )
  19.  
  20. mycursor = mydb.cursor()
  21.  
  22. mycursor.execute("SElECT * FROM `registration` WHERE `key`");
  23.  
  24. row_count = mycursor.rowcount();
  25.  
  26. if row_count = 1 :
  27.    
  28.    
  29.    
  30.  
  31.  
  32. row = mycursor.fetchone()
  33.  
  34.  
  35.  
  36.  
  37. if row.status = "ACTIVE" :
  38.    
  39.     if row.validity > datetime.timestamp(datetime.now()) :
  40.        
  41.  
  42.  
  43.  
  44. for r in rows :
  45.     r[0];
  46.     r[1];
  47.     r[2];
  48.  
  49. for x in mycursor:
  50.   print(x)
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65. def validate_request(key):
  66.     mydb = mysql.connector.connect(
  67.   host="localhost",
  68.   user="yourusername",
  69.   passwd="yourpassword",
  70.   database="mydatabase"
  71. )
  72.  
  73. mycursor = mydb.cursor()
  74.  
  75. mycursor.execute("SElECT * FROM `registration` WHERE `key`");
  76.  
  77. row_count = mycursor.rowcount();
  78.  
  79. if row_count = 1 :
  80.    
  81.    
  82.    
  83.  
  84.  
  85. row = mycursor.fetchone()
  86.  
  87.  
  88.  
  89.  
  90. if row.status = "ACTIVE" :
  91.    
  92.     if row.validity > datetime.timestamp(datetime.now()) :
  93.        
  94.  
  95.  
  96.  
  97. for r in rows :
  98.     r[0];
  99.     r[1];
  100.     r[2];
  101.  
  102. for x in mycursor:
  103.   print(x)
  104.  
  105.  
  106.  
  107.  
  108.  
  109.    
  110.    
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128. #schema
  129.  
  130. Table name
  131.  
  132.     registration
  133.  
  134.         key
  135.         reg_date
  136.         expiry_date
  137.         name
  138.         email_id
  139.         active_status
  140.     services
  141.        
  142.         email_id
  143.         spam_predictor
Add Comment
Please, Sign In to add comment