title: Editing Python Class in Shell and SQLAlchemy
body: <p>I'm working on in the terminal on a shell script following this tutorial <a href="http://docs.sqlalchemy.org/en/latest/orm/tutorial.html" rel="nofollow">http://docs.sqlalchemy.org/en/latest/orm/tutorial.html</a> SQLAlchemy tutorial on Declare A Mapping. I needed to type in </p>
  
  <pre><code>&gt;&gt;&gt; from sqlalchemy import Column, Integer, String
  &gt;&gt;&gt; class User(Base):
          __tablename__ = 'users'
          id = Column(Integer, primary_key=True)
          name = Column(String)
          fullname = Column(String)
          password = Column(String)
  
          def __repr__(self):
              return "&lt;\User(name='%s', fullname='%s', password='%s')&gt;" % (
                  self.name, self.fullname, self.password)
  </code></pre>
  
  <p>Issue is after I typed the password = Column(String) I hit enter twice and the .... changed to >>>. I then retyped everything back in but then an error was thrown because the class already exists... I'm not totally sure how to fix this. How do I open up that class in the shell script and edit it (add in the def repr)</p>
  
  <p>The error thrown is below:</p>
  
  <pre><code>/Users/GaryPeters/TFsqlAlc001/lib/python2.7/site-packages/sqlalchemy/ext/declarative/clsregistry.py:160: SAWarning: This declarative base already contains a class with the same class name and module name as __main__.User, and will be replaced in the string-lookup table.
    existing.add_item(cls)
  
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  
    File "/Users/GaryPeters/TFsqlAlc001/lib/python2.7/site-packages/sqlalchemy/ext/declarative/api.py", line 53, in __init__
      _as_declarative(cls, classname, cls.__dict__)
  
    File "/Users/GaryPeters/TFsqlAlc001/lib/python2.7/site-packages/sqlalchemy/ext/declarative/base.py", line 251, in _as_declarative
      **table_kw)
  
    File "/Users/GaryPeters/TFsqlAlc001/lib/python2.7/site-packages/sqlalchemy/sql/schema.py", line 339, in __new__
      "existing Table object." % key)
  
  sqlalchemy.exc.InvalidRequestError: Table 'users' is already defined for this MetaData instance.  Specify 'extend_existing=True' to redefine options and columns on an existing Table object.
  </code></pre>