Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.01 KB | None | 0 0
  1. import sqlite3
  2.  
  3. def loginTable():
  4.     #Connecting or Creating a Database
  5.     loginconnection = sqlite3.connect("Login_table.db")
  6.     print("Successful connected / Created")
  7.  
  8.     #Creating a Table in the Database
  9.     loginconnection.execute("CREATE TABLE LOGIN_TABLE (USERNAME TEXT,PASSWORD TEXT)")
  10.     print("Successfully Created")
  11.  
  12.     #inserting Data collection into Database
  13.     loginconnection.execute("INSERT INTO LOGIN_TABLE VALUES(?,?)",("admin","awosanya"))
  14.  
  15.     loginconnection.commit()
  16.     print("Successful inserted")
  17.  
  18.     #Update info a database
  19.  
  20.     #Loginconnection.execute("UPDATE LOGIN_TABLE set PASSWORD = admin  where USERNAME = Admin")
  21.     #Loginconnection.execute("DELETE from LOGIN_TABLE where USERNAME=Admin")
  22.    
  23.  
  24.     #selction of data from the database
  25.     result = loginconnection.execute("SELECT * FROM LOGIN_TABLE")
  26.     for data in result:
  27.         print("Username : ", data[0])
  28.         print("password : ", data[1])
  29.  
  30.    
  31.  
  32.     loginconnection.close()
  33.  
  34.  
  35. loginTable()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement