Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- import sqlite3 as db
- #регистрация
- print 'input reg for reg or enter your name'
- _id = raw_input()
- if _id == 'reg':
- name = raw_input("Choose your name: ")
- conn = db.connect('users.db')
- c = conn.cursor()
- player = c.execute("SELECT COUNT(login) FROM users WHERE users.login=?", (name,))
- playercount = c.fetchone()
- while playercount[0] !=0:
- c.execute("SELECT COUNT(login) FROM users WHERE users.login=?", (name,))
- playercount = c.fetchone()
- print playercount[0]
- if playercount[0] !=0:
- name = raw_input('User exists. Enter your name: ')
- else:
- pwd = raw_input('Придумай себе пароль: ')
- pwd1 = raw_input('Пароль еще раз: ')
- while pwd != pwd1:
- print 'Пароли не совпадают! Повтори ввод.'
- pwd = raw_input('Придумай себе пароль: ')
- pwd1 = raw_input('Пароль еще раз: ')
- else:
- c.execute("INSERT INTO users(login, password) VALUES (?, ?)", (name, pwd, ))
- print 'OK'
- #c.execute("SELECT login, password FROM users")
- #xx = c.fetchall()
- #print xx
- conn.commit()
- c.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement