how to store default username and password for login system test in sqlalchemy
Question: Trying to make a simple login system in Python using pyramid framework. What I
want to be able to do now is for example if we're working in php we can easily
open phpmyadmin and set a fields with username and password that we can use to
test the login system.

**How can I do this in python pyramid project using sqlalchemy**

This is my model class where I created my table structure

    
    
    from test2.models.meta import Base
    from which model classes will inherit
    from sqlalchemy import (
        Column,
        Integer,
        Unicode,     #<- will provide Unicode field
        UnicodeText, #<- will provide Unicode text field
        Text,
        )
    
    class Users(Base):
            __tablename__ = 'users'
            id = Column(Integer, primary_key=True)
            name = Column(Text, unique=True, nullable=False,default='admin')
            password = Column(Text, nullable=False,default='password')
    
    
    from pyramid.view import view_config
    from test2.models.services.userservice import UserServices
    from pyramid.httpexceptions import HTTPFound, HTTPNotFound
    from pyramid.security import remember,forget
    

This is the view config

    
    
    @view_config(route_name='auth',match_param='action=in',renderer='string',request_method='POST')
    @view_config(route_name='auth', match_param='action=out', renderer='string')
    def dashboard(request):
            username=request.POST.get('username')
            if username:
                user=UserServices.by_name(username)
                if user and user.verify_password(request.POST.get('password')):
                    return HTTPFound(location=request.route_url('home'))
                else:
                    headers=forget(request)
            else:
                #return HTTPNotFound
                headers=forget(request)
            return HTTPFound(location=request.route_url('home'),headers=headers)
    

**What I want to achieve is a simple login system which tests the username and
password then redirects**


Answer: There are two versions of the official Pyramid tutorial, "SQLAlchemy + URL
Dispatch Wiki Tutorial", which show both the wrong and right way for storing
passwords:

  * [Latest (v.1.6)](http://docs.pylonsproject.org/projects/pyramid/en/latest/tutorials/wiki2/index.html)
  * [Master (unreleased)](http://docs.pylonsproject.org/projects/pyramid/en/master/tutorials/wiki2/index.html)

In the "latest" branch, you will find [how to set passwords in
cleartext](http://docs.pylonsproject.org/projects/pyramid/en/latest/tutorials/wiki2/authorization.html).
**This is absolutely the wrong way to store passwords.**

In the "master" branch, [we hash
passwords](http://docs.pylonsproject.org/projects/pyramid/en/master/tutorials/wiki2/definingmodels.html).

Always hash passwords with a strong cryptographic algorithm that already
exists, like `bcrypt`, and never attempt to write your own. Also, to be
pedantic, one "hashes" passwords and does not "encrypt" them. Hashing is a
one-way only operation, whereas encrypting can be reversed (decrypting).

