Autocommit is false because we don't want to commit changes to the db until we explicitly tell the program to do so; autoflush will automatically send all data to the pending transaction. Expire on commit will cause the session to expire when you commit - we don't want that. Then we bind the session to the db engine (created above).

Sessionmaker creates an sql alchemy session object and scoped_session scopes it properly to keep things tidy and allow you to use it in multiple areas of the application without confusion.