Guest User

Untitled

a guest
Sep 13th, 2018
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. import os
  2. import sqlite3
  3.  
  4. dir='/home/davidmn/Dropbox/Python/Other'
  5. dbname='userdb.db'
  6. dblocation=dir+'/'+dbname
  7. os.chdir(dir)
  8. list=str(os.system('ls'))
  9.  
  10. def dbjob():
  11. if dbname not in list:
  12. username=str(raw_input('Enter a user name: '))
  13. password=str(raw_input('Enter a password: '))
  14. os.system('cd '+dir)
  15. os.system('touch '+dbname)
  16. dbcreate=sqlite3.connect(dblocation)
  17. dbcurs=dbcreate.cursor()
  18. dbcurs.execute('''CREATE TABLE users
  19. (id INTEGER PRIMARY KEY, username TEXT, password TEXT)''')
  20. dbcurs.execute('''INSERT INTO users
  21. VALUES (0,?,?)''', (username, password))
  22. dbcurs.close()
  23.  
  24.  
  25. dbjob()
Add Comment
Please, Sign In to add comment