Advertisement
j7sx

reg (users, password) рабочая

Oct 21st, 2013
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.19 KB | None | 0 0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3.  
  4. import sqlite3 as db
  5.  
  6. #регистрация
  7. print 'input reg for reg or enter your name'
  8. _id = raw_input()
  9. if _id == 'reg':
  10.   name = raw_input("Choose your name: ")
  11.   conn = db.connect('users.db')
  12.   c = conn.cursor()
  13.   player = c.execute("SELECT COUNT(login) FROM users WHERE users.login=?", (name,))
  14.   playercount = c.fetchone()
  15.   while playercount[0] !=0:
  16.     c.execute("SELECT COUNT(login) FROM users WHERE users.login=?", (name,))
  17.     playercount = c.fetchone()
  18.     print playercount[0]
  19.     if playercount[0] !=0:
  20.       name = raw_input('User exists. Enter your name: ')
  21.   else:
  22.     pwd = raw_input('Придумай себе пароль: ')
  23.     pwd1 = raw_input('Пароль еще раз: ')
  24.     while pwd != pwd1:
  25.       print 'Пароли не совпадают! Повтори ввод.'
  26.       pwd = raw_input('Придумай себе пароль: ')
  27.       pwd1 = raw_input('Пароль еще раз: ')
  28.     else:  
  29.       c.execute("INSERT INTO users(login, password) VALUES (?, ?)", (name, pwd, ))
  30.   print 'OK'
  31.   #c.execute("SELECT login, password FROM users")
  32.   #xx = c.fetchall()
  33.   #print xx
  34.   conn.commit()
  35.   c.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement