= re.sub("[\W_]+", '', login)
query = QSqlQuery('SELECT COUNT(*) FROM users WHERE Name=":{}"'.format(login),db=mydb)
query.first()
tmp = query.record().indexOf("Name")
value = str()
while query.next():
value = query.value(tmp)
if value != None:
signal.emit('Name already used!')
elif value == None:
query = QSqlQuery(db=mydb)
query.prepare("INSERT INTO users (Name, Password)"
" VALUES (?, ?)")
query.bindValue(1, login)
query.bindValue(2, password)
query.exec_()
signal.emit('Registration successed!')
bool QSqlQuery::first() Retrieves the first record in the result, if available, and positions the query on the retrieved record. Note that the result must be in the active state and isSelect() must return true before calling this function or it will do nothing and return false. Returns true if successful. If unsuccessful the query position is set to an invalid position and false is returned.
Обсуждают сегодня