Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7528647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:26:21+00:00 2026-05-30T04:26:21+00:00

I am a newbie – just reached the end of Learn Python the Hard

  • 0

I am a newbie – just reached the end of Learn Python the Hard Way and am now trying my hand at Flask. I started with the official tutorial at the Flask website, but am getting stuck at this step:

from __future__ import with_statement
import sqlite3
from flask import Flask, request, session, g, redirect, url_for, abort, render_template, flash
from contextlib import closing

DATABASE = 'tmp/flaskr.db'
DEBUG = True
SECRET_KEY = 'development key'
USERNAME = 'admin'
PASSWORD = 'default'

app = Flask(__name__)
app.config.from_object(__name__)

app.config.from_envvar('FLASKR_SETTINGS',silent=True)

def connect_db():
        return sqlite3.connect(app.config['DATABASE'])

def init_db():
    with closing(connect_db()) as db:
        with app.open.resource('schema.sql') as f:
            db.cursor.executescript(f.read())
        db.commit()

if __name__ == '__main__':
    app.run()

At the Python Shell, if I do

from flaskr import init_db
init_db() 

I see: Attribute Error: Flask object has no attribute 'open' (in the line containing app.open.resource in init_db). How do i fix this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T04:26:24+00:00Added an answer on May 30, 2026 at 4:26 am

    Your code:

    app.open.resource
    

    The example code:

    app.open_resource
    

    Can you spot the difference? In case you can’t, the example code uses an underscore where you use a dot. A Flask object has no attribute called open, but it does have a method called open_resource.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Newbie question (I'm just getting started with Python and Pydev): I've created a project
Newbie to C++ but I am a Java programmer. Trying to learn C++ now.
Newbie still learning, been trying to search and hack code together for hours now,
Newbie to LINQ, and trying to write the following query... select f.Section_ID, f.Page_ID, f.SortOrder,
Newbie question: I just installed VisualSVN Server and created a repository. I noticed that
Newbie question since I'm not up to speed using maven at all. I'm trying
Newbie question. I am trying to use ActiveRecord::Base.connection.execute(..) in a ruby 3.1 app and
Newbie Alert: I'm new to Python and when I'm basically adding values to a
Newbie here with a frustrating, but probably simple question. I am trying to write
Newbie to Python, so this may seem silly. I have two dicts: default =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.