{"action":"created","issue":{"url":"https://api.github.com/repos/pallets/flask/issues/2772","repository_url":"https://api.github.com/repos/pallets/flask","labels_url":"https://api.github.com/repos/pallets/flask/issues/2772/labels{/name}","comments_url":"https://api.github.com/repos/pallets/flask/issues/2772/comments","events_url":"https://api.github.com/repos/pallets/flask/issues/2772/events","html_url":"https://github.com/pallets/flask/issues/2772","id":322419794,"number":2772,"title":"\"flask init-db\" isn't working","user":{"login":"naveenmalla046","id":30531283,"avatar_url":"https://avatars3.githubusercontent.com/u/30531283?v=4","gravatar_id":"","url":"https://api.github.com/users/naveenmalla046","html_url":"https://github.com/naveenmalla046","followers_url":"https://api.github.com/users/naveenmalla046/followers","following_url":"https://api.github.com/users/naveenmalla046/following{/other_user}","gists_url":"https://api.github.com/users/naveenmalla046/gists{/gist_id}","starred_url":"https://api.github.com/users/naveenmalla046/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/naveenmalla046/subscriptions","organizations_url":"https://api.github.com/users/naveenmalla046/orgs","repos_url":"https://api.github.com/users/naveenmalla046/repos","events_url":"https://api.github.com/users/naveenmalla046/events{/privacy}","received_events_url":"https://api.github.com/users/naveenmalla046/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-05-11T20:10:59Z","updated_at":"2018-05-18T23:35:46Z","closed_at":"2018-05-12T15:20:31Z","author_association":"NONE","body":"This code must be placed in the __init__.py as per the documentation: http://flask.pocoo.org/docs/1.0/tutorial/database/    (Section: Register with the Application)\r\n\r\n    flaskr/__init__.py\r\n    def create_app():\r\n      app = ...\r\n      # existing code omitted\r\n\r\n    from . import db\r\n    db.init_app(app)\r\n\r\n    return app\r\n\r\n----------------------------------------------\r\n\r\nThis is the __init__.py code after copying that code\r\n\r\n    import os\r\n\r\n    from flask import Flask\r\n\r\n    def create_app(test_config=None):\r\n    # create and configure the app\r\n    app = Flask(__name__, instance_relative_config=True)\r\n    app.config.from_mapping(\r\n        SECRET_KEY='dev',\r\n        DATABASE=os.path.join(app.instance_path, 'flaskr.sqlite'),\r\n    )\r\n\r\n    if test_config is None:\r\n        # load the instance config, if it exists, when not testing\r\n        app.config.from_pyfile('config.py', silent=True)\r\n    else:\r\n        # load the test config if passed in\r\n        app.config.from_mapping(test_config)\r\n\r\n    # ensure the instance folder exists\r\n    try:\r\n        os.makedirs(app.instance_path)\r\n    except OSError:\r\n        pass\r\n\r\n    # a simple page that says hello\r\n    @app.route('/hello')\r\n    def hello():\r\n        return 'Hello, World!'\r\n   \r\n    #database \r\n    from . import db\r\n    db.init_app(app)\r\n\r\n    return app\r\n\r\n\r\nExpected output:\r\n\r\nRun the init-db command:\r\n\r\nflask init-db\r\nInitialized the database.\r\nThere will now be a flaskr.sqlite file in the instance folder in your project.\r\n\r\nI'm getting an error while executing the above command:\r\nflask init-db\r\nUsage: flask [OPTIONS] COMMAND [ARGS]...\r\n\r\nError: No such command \"init-db\".\r\n\r\nI even tried copying the exact code from the repo https://github.com/pallets/flask/blob/746b91dfced525651c9b71a3bd075a78d2b9262f/examples/tutorial/flaskr/__init__.py\r\nit is not working even though, same error.\r\n\r\nPls help me with this I'm new to flask and i'm stuck here. cannot proceed further in the documentation unless this code executes\r\n"},"comment":{"url":"https://api.github.com/repos/pallets/flask/issues/comments/390358291","html_url":"https://github.com/pallets/flask/issues/2772#issuecomment-390358291","issue_url":"https://api.github.com/repos/pallets/flask/issues/2772","id":390358291,"user":{"login":"dtamez","id":58890,"avatar_url":"https://avatars3.githubusercontent.com/u/58890?v=4","gravatar_id":"","url":"https://api.github.com/users/dtamez","html_url":"https://github.com/dtamez","followers_url":"https://api.github.com/users/dtamez/followers","following_url":"https://api.github.com/users/dtamez/following{/other_user}","gists_url":"https://api.github.com/users/dtamez/gists{/gist_id}","starred_url":"https://api.github.com/users/dtamez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtamez/subscriptions","organizations_url":"https://api.github.com/users/dtamez/orgs","repos_url":"https://api.github.com/users/dtamez/repos","events_url":"https://api.github.com/users/dtamez/events{/privacy}","received_events_url":"https://api.github.com/users/dtamez/received_events","type":"User","site_admin":false},"created_at":"2018-05-18T23:35:46Z","updated_at":"2018-05-18T23:35:46Z","author_association":"NONE","body":"looks like the problem might be a typo:\r\ndef inti_app(app):\r\n\r\ninstead of \"init_app\".\r\nDoes that fix the issue?"}}
{"actor":{"display_login":"dtamez"}}