Issue
I'm building a web app in Flask. I'm a noob. This is my first app.
I have followed installation instructions for SQLite, and now I have SQLite on my machine.
How do I include SQLite in my app? I need to be able to use SQLite in my app.py
Do I need to include SQLite in the virtual environment? How do I do that?
Here is the directory I'm working in
Solution
in first you should import SQLlite like
import sqlite3 # this library is have from first time in your python so no need to download
after should create data base like :
con = sqlite3.connect('mydatabase.db') # create data base and give name like mydatabase
# but should in last have .db
cur = con.cursor() # for send parameter always you need this
after you can create table for your database to store you items like:
cur.execute("CREATE TABLE IF NOT EXISTS session_id (id INTEGER PRIMARY KEY,what yo want MESSAGE_TEXT ,pass_word FLOAT )")
# with cur.execute first can i created id in my table like every project its good
# its good to create this for store your items in your database and you create..
# any you want like what you want for ex. create name should MESSAGE_TEXT, and..
# password like INTEGER OR FLOAT OR DOUBLE what you want
con.commit()
and you can send parameter like this to your table:
cur.execute("INSERT INTO my_table VALUES name,password))
# in here i just send to parameter because we just create to item in our database
# you can create more, like name, password, session or what you want
con.commit() # and again this because should always have
If I want to talk about it at all, it will be too much, That's why I shared the link of an article for you here so that you can learn much better and deeper
Link for more here »» Link
https://www.tutorialspoint.com/sqlite/sqlite_python.htm
Answered By - Matin Answer Checked By - Marilyn (WPSolving Volunteer)