Well, there is one thing you are missing: the tutorial you mention doesn’t “build” a complete example, the different snippets of code are not meant to be concatenated into one source file. Rather, they describe the different ways the library can be used. No need to try and do the same thing over and over again yourself.
Leaving out the actually-using-the-orm part from your example, the code could look like this:
from sqlalchemy import *
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker, scoped_session
engine = create_engine('sqlite:///:memory:', echo=True)
Base = declarative_base(bind=engine)
Session = scoped_session(sessionmaker(engine))
class User(Base):
__tablename__ = 'users'
id = Column(Integer, primary_key=True)
name = Column(String)
fullname = Column(String)
password = Column(String)
Base.metadata.create_all()
The “declarative” extension takes care of defining the table and mapping it to your class, so you don’t need to declare the users_table yourself. The User class will also allow instantiating with keyword arguments, like User(name="foo"), (but not positional arguments though).
I’ve also added use of scoped_session, which means you can directly use Session without actually having to instantiate it (it will instantiate a new session if there isn’t already one present in the current thread, or reuse the existing one otherwise)