{"action":"created","issue":{"url":"https://api.github.com/repos/pallets/flask/issues/1978","repository_url":"https://api.github.com/repos/pallets/flask","labels_url":"https://api.github.com/repos/pallets/flask/issues/1978/labels{/name}","comments_url":"https://api.github.com/repos/pallets/flask/issues/1978/comments","events_url":"https://api.github.com/repos/pallets/flask/issues/1978/events","html_url":"https://github.com/pallets/flask/issues/1978","id":169376236,"number":1978,"title":"docs: sqlalchemy pattern document has an invalid import","user":{"login":"sc68cal","id":506899,"avatar_url":"https://avatars.githubusercontent.com/u/506899?v=3","gravatar_id":"","url":"https://api.github.com/users/sc68cal","html_url":"https://github.com/sc68cal","followers_url":"https://api.github.com/users/sc68cal/followers","following_url":"https://api.github.com/users/sc68cal/following{/other_user}","gists_url":"https://api.github.com/users/sc68cal/gists{/gist_id}","starred_url":"https://api.github.com/users/sc68cal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sc68cal/subscriptions","organizations_url":"https://api.github.com/users/sc68cal/orgs","repos_url":"https://api.github.com/users/sc68cal/repos","events_url":"https://api.github.com/users/sc68cal/events{/privacy}","received_events_url":"https://api.github.com/users/sc68cal/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-08-04T13:37:53Z","updated_at":"2016-08-08T16:16:53Z","closed_at":"2016-08-08T02:04:34Z","body":"The [declarative](https://github.com/pallets/flask/blob/master/docs/patterns/sqlalchemy.rst#declarative) section includes the following example:\r\n\r\n```\r\nDeclarative\r\n-----------\r\n\r\nThe declarative extension in SQLAlchemy is the most recent method of using\r\nSQLAlchemy.  It allows you to define tables and models in one go, similar\r\nto how Django works.  In addition to the following text I recommend the\r\nofficial documentation on the `declarative`_ extension.\r\n\r\nHere's the example :file:`database.py` module for your application::\r\n\r\n    from sqlalchemy import create_engine\r\n    from sqlalchemy.orm import scoped_session, sessionmaker\r\n    from sqlalchemy.ext.declarative import declarative_base\r\n\r\n    engine = create_engine('sqlite:////tmp/test.db', convert_unicode=True)\r\n    db_session = scoped_session(sessionmaker(autocommit=False,\r\n                                             autoflush=False,\r\n                                             bind=engine))\r\n```\r\n\r\n`db_session` is a variable, and a paragraph below, it tries to import it. Which isn't really possible.\r\n\r\n```\r\n\r\n    from yourapplication.database import db_session\r\n\r\n    @app.teardown_appcontext\r\n    def shutdown_session(exception=None):\r\n        db_session.remove()\r\n```\r\n\r\nThis documentation is misleading "},"comment":{"url":"https://api.github.com/repos/pallets/flask/issues/comments/238288472","html_url":"https://github.com/pallets/flask/issues/1978#issuecomment-238288472","issue_url":"https://api.github.com/repos/pallets/flask/issues/1978","id":238288472,"user":{"login":"sc68cal","id":506899,"avatar_url":"https://avatars.githubusercontent.com/u/506899?v=3","gravatar_id":"","url":"https://api.github.com/users/sc68cal","html_url":"https://github.com/sc68cal","followers_url":"https://api.github.com/users/sc68cal/followers","following_url":"https://api.github.com/users/sc68cal/following{/other_user}","gists_url":"https://api.github.com/users/sc68cal/gists{/gist_id}","starred_url":"https://api.github.com/users/sc68cal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sc68cal/subscriptions","organizations_url":"https://api.github.com/users/sc68cal/orgs","repos_url":"https://api.github.com/users/sc68cal/repos","events_url":"https://api.github.com/users/sc68cal/events{/privacy}","received_events_url":"https://api.github.com/users/sc68cal/received_events","type":"User","site_admin":false},"created_at":"2016-08-08T16:16:53Z","updated_at":"2016-08-08T16:16:53Z","body":"That's a post of me trying to follow the documentation, albiet with a module named `api` instead of `database` like the instructions has.\r\n\r\nThere is no `db_session.py` that the docs includes. The docs talk about a `database.py` module. So if anything it should be \r\n\r\n```\r\nfrom yourapplication.database import database\r\n```\r\n\r\nAnd I guess it would be `database.db_session.close()` ?\r\n\r\nThe issue is the docs are quite ambiguous."}}
{"actor":{"display_login":"sc68cal"}}