Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import sqlite3
- dir='/home/davidmn/Dropbox/Python/Other'
- dbname='userdb.db'
- dblocation=dir+'/'+dbname
- os.chdir(dir)
- list=str(os.system('ls'))
- def dbjob():
- if dbname not in list:
- username=str(raw_input('Enter a user name: '))
- password=str(raw_input('Enter a password: '))
- os.system('cd '+dir)
- os.system('touch '+dbname)
- dbcreate=sqlite3.connect(dblocation)
- dbcurs=dbcreate.cursor()
- dbcurs.execute('''CREATE TABLE users
- (id INTEGER PRIMARY KEY, username TEXT, password TEXT)''')
- dbcurs.execute('''INSERT INTO users
- VALUES (0,?,?)''', (username, password))
- dbcurs.close()
- dbjob()
Add Comment
Please, Sign In to add comment