Reputation: 132
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)
Upvotes: 1
Views: 401
Reputation: 2909
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
Upvotes: 1