Managing Blob of SQLite database table

Basics of Python Tkinter Full code with sample images

The main script is same for both the databases, only the connection string and the place holder for parameters in SQL is changed.

The changes required for using SQLite database in place of MySQL database is here.

Connection to SQLite Database

The connection object my_conn is created by using SQLite database, so in all script this line is to be changed.
my_conn = create_engine("mysql+mysqldb://userid:password@localhost/db_name")
For SQLite ( Change the path )
my_conn = create_engine("sqlite:///D:\\testing\\sqlite\\my_db.db")
While using placeholder for parameterized query for MySQL
    id=my_conn.execute("INSERT INTO  student_profile(id,student,profile_photo) \
                  VALUES (%s,%s,%s)",data)
For SQLite
    id=my_conn.execute("INSERT INTO  student_profile(id,student,profile_photo) \
                  VALUES (?,?,?)",data)
To create table and database in SQLite
from sqlalchemy import create_engine
from sqlalchemy.exc import SQLAlchemyError
        my_conn = create_engine("sqlite:///D:\\testing\\sqlite\\my_db.db")
        print("Created database successfully")
                CREATE TABLE IF NOT EXISTS student_profile(id integer, 
                      student text, 
                      profile_photo blob
        print("Student Table created successfully")
except SQLAlchemyError as e:
        error = str(e.__dict__['orig'])

Displaying records from student table
Subscribe to our YouTube Channel here


* indicates required
Subscribe to plus2net

    Post your comments , suggestion , error , requirements etc here

    Python Video Tutorials
    Python SQLite Video Tutorials
    Python MySQL Video Tutorials
    Python Tkinter Video Tutorials
    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2022 All rights reserved worldwide Privacy Policy Disclaimer