1

Im trying to use sqlite3 for my python project. I need to make a register page to register users for accessing other features. so I need to check if the username or email exists or not . and I have been forbidden using ORM (sorry for my bad English ).the only tutorial that I have passed is this :http://flask.pocoo.org/docs/0.10/tutorial/introduction/ but I dont know how to work with database,how to get table information and cells and ... can you please tell me how or give me a reference? I think I must know some commands like this :

@app.route('/')
def show_entries():
    #specially this line
    cur = g.db.execute('select title, text from entries order by id desc')
    entries = [dict(title=row[0], text=row[1]) for row in cur.fetchall()]
    return render_template('show_entries.html', entries=entries)
3
  • Take a look at source code from tutorial. It should help! Commented Jan 19, 2016 at 13:02
  • I have done this little app it works fine. I only want to work with sqlite3 database from my python project. Commented Jan 19, 2016 at 13:31
  • You need to know some SQL; know how to use python with sqlite3(built-in module: sqlite3), how to use sqlite3 with flask(Using SQLite 3 with Flask). Commented Jan 19, 2016 at 14:28

1 Answer 1

1

Basically it looks like this:

t = ('RHAT',)
c.execute('SELECT * FROM stocks WHERE symbol=?', t)
print c.fetchone()

More comprehensive examples could be found here: https://docs.python.org/2/library/sqlite3.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.