Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6334703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:42:36+00:00 2026-05-24T18:42:36+00:00

from sqlalchemy import create_engine from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey from

  • 0
from sqlalchemy import create_engine
from sqlalchemy import Table, Column, Integer, String, MetaData, ForeignKey
from sqlalchemy.orm import mapper, sessionmaker
from sqlalchemy.ext.declarative import declarative_base

from bottle import route, post, get, request
import os

Base = declarative_base()

class User(Base):
    """Table for login details"""
    __tablename__ = 'login_table'
    id = Column(Integer, primary_key=True)
    username =  Column(String)
    password =  Column(String)
    email = Column(String)

    def __init__(self, username, password, email):
        """Create a object containing info of a user"""
        self.username = username
        self.password = password
        self.email = email

    def __str__(self):
        """Return a string representation"""
        return self.username

    def __repr__(self):
        """Return a object representation"""
        return "<User(%s)>" % self.username

def force_engine():
    engine = create_engine('sqlite:///users.db', echo=True)
    Base.metadata.create_all(engine)
    Session = sessionmaker()
    Session.configure(bind=engine)
    session = Session()
    session.commit()

def spawn_session():
    engine = create_engine('sqlite:///users.db')
    Session = sessionmaker()
    Session.configure(bind=engine)
    return Session()

def create_user(username, password, email):
    session = spawn_session()
    session.add(User(username, password, email))
    session.commit()
    return True

def register_test():
    create_user('dave','test', 'a')
    create_user('cat','123','a')

if not os.path.exists('users.db'):
    force_engine()

@get('/register')
def register_form():
    return '''<form method="POST">
                <p>Welcome new user. Enter a username, password, email.</p></br>
                <p>Username: </p><input name="username" type="text" /></br>
                <p>Password: </p><input name="password" type="password" /></br>
                <p>Email: </p><input name="email" type="text" /></br>
                <input type="submit" value="Submit" />
              </from>'''

@post('/register')
def register_submit():
    name     = request.forms.get('username')
    password = request.forms.get('password')
    email = request.forms.get('email')
    authd = create_user(name, password, email)
    if authd:
        return "<p>User created</p>"
    else:
        return "<p>Failure</p>"

This is the code I’m using. Don’t tell me about security, or anything else. Just help me figure out why its causing this traceback

>>> register_test()
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "C:\Users\Public\Documents\webapps\login\register.py", line 54, in register_test
    create_user('dave','test', 'a')
  File "C:\Users\Public\Documents\webapps\login\register.py", line 50, in create_user
    session.commit()
  File "C:\Python26\lib\site-packages\sqlalchemy-0.6.5-py2.6.egg\sqlalchemy\orm\session.py", line 623, in commit
    self.transaction.commit()
  File "C:\Python26\lib\site-packages\sqlalchemy-0.6.5-py2.6.egg\sqlalchemy\orm\session.py", line 385, in commit
    self._prepare_impl()
  File "C:\Python26\lib\site-packages\sqlalchemy-0.6.5-py2.6.egg\sqlalchemy\orm\session.py", line 369, in _prepare_impl
    self.session.flush()
  File "C:\Python26\lib\site-packages\sqlalchemy-0.6.5-py2.6.egg\sqlalchemy\orm\session.py", line 1397, in flush
    self._flush(objects)
  File "C:\Python26\lib\site-packages\sqlalchemy-0.6.5-py2.6.egg\sqlalchemy\orm\session.py", line 1478, in _flush
    flush_context.execute()
  File "C:\Python26\lib\site-packages\sqlalchemy-0.6.5-py2.6.egg\sqlalchemy\orm\unitofwork.py", line 304, in execute
    rec.execute(self)
  File "C:\Python26\lib\site-packages\sqlalchemy-0.6.5-py2.6.egg\sqlalchemy\orm\unitofwork.py", line 448, in execute
    uow
  File "C:\Python26\lib\site-packages\sqlalchemy-0.6.5-py2.6.egg\sqlalchemy\orm\mapper.py", line 1872, in _save_obj
    execute(statement, params)
  File "C:\Python26\lib\site-packages\sqlalchemy-0.6.5-py2.6.egg\sqlalchemy\engine\base.py", line 1191, in execute
    params)
  File "C:\Python26\lib\site-packages\sqlalchemy-0.6.5-py2.6.egg\sqlalchemy\engine\base.py", line 1271, in _execute_clauseelement
    return self.__execute_context(context)
  File "C:\Python26\lib\site-packages\sqlalchemy-0.6.5-py2.6.egg\sqlalchemy\engine\base.py", line 1302, in __execute_context
    context.parameters[0], context=context)
  File "C:\Python26\lib\site-packages\sqlalchemy-0.6.5-py2.6.egg\sqlalchemy\engine\base.py", line 1401, in _cursor_execute
    context)
  File "C:\Python26\lib\site-packages\sqlalchemy-0.6.5-py2.6.egg\sqlalchemy\engine\base.py", line 1394, in _cursor_execute
    context)
  File "C:\Python26\lib\site-packages\sqlalchemy-0.6.5-py2.6.egg\sqlalchemy\engine\default.py", line 299, in do_execute
    cursor.execute(statement, parameters)
OperationalError: (OperationalError) table login_table has no column named email u'INSERT INTO login_table (username, password, email) VALUES (?, ?, ?)' ('dave', 'test', 'a')

Even when I close down python entirely, and delete the database entirely I still get the same execption

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T18:42:38+00:00Added an answer on May 24, 2026 at 6:42 pm

    Very nice write up here about using SQLAlchemy and SQLite in this tutorial

    You need to verify that you are on at least version 0.7 of SQLAlchemy

    >>> import sqlalchemy
    >>> sqlalchemy.__version__ 
    0.7.0
    

    use echo to display the SQL generated

    >>> from sqlalchemy import create_engine
    >>> engine = create_engine('sqlite:///users.db', echo=True)
    

    and you might have missed this very important step

    >>> from sqlalchemy.ext.declarative import declarative_base
    >>> Base = declarative_base()
    

    finally verify that you have created the table correctly

    >>> User.__table__ 
    Table('users', MetaData(None),
                Column('id', Integer(), table=<users>, primary_key=True, nullable=False),
                Column('name', String(), table=<users>),
                Column('username', String(), table=<users>),
                Column('password', String(), table=<users>), 
                Column('email', String(), table=<users>), schema=None)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Code replicating the error: from sqlalchemy import create_engine, Table, Column, Integer from sqlalchemy.ext.declarative import
Here's my code: from sqlalchemy import create_engine, Column, Integer from sqlalchemy.ext.declarative import declarative_base from
The SQLAlchemy ORM tutorial uses this class: >>> from sqlalchemy import Column, Integer, String
I have created a table (MySQL 5.1) from sqlalchemy import * def get(): db
Consider the following snippet of Python code: from sqlalchemy import * from sqlalchemy.orm import
Here's what I've got: from sqlalchemy import * from sqlalchemy.orm import * from web.models.card
How do I select one or more random rows from a table using SQLAlchemy?
I'm looking for an easy python way to compare column types from SQLAlchemy to
Python noob here, Currently I'm working with SQLAlchemy, and I have this: from __init__
I'm confused about how to concurrently modify a table from several different processes. I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.