Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
.exe prob
#1
import sqlite3

def writeTofile(data, filename):
    # Convert binary data to proper format and write it on Hard Disk
    with open(filename, 'wb') as file:
        file.write(data)
    #print("Stored blob data into: ", filename, "\n")

def readBlobData(empId):
    try:
        sqliteConnection = sqlite3.connect('SQLite_Python.db')
        cursor = sqliteConnection.cursor()
        print("Connected to SQLite")

        sql_fetch_blob_query = """SELECT * from new_employee where id = ?"""
        cursor.execute(sql_fetch_blob_query, (empId,))
        record = cursor.fetchall()
        for row in record:
            #print("Id = ", row[0], "Name = ", row[1])
            name  = row[1]
            photo = row[2]
            

            print("Storing employee image and resume on disk \n")
            photoPath = r"C:\AdwCleaner\\" + name + ".txt"
            
            writeTofile(photo, photoPath)
            

        cursor.close()

    except sqlite3.Error as error:
        print("Failed to read blob data from sqlite table", error)
    finally:
        if (sqliteConnection):
            sqliteConnection.close()
            print("sqlite connection is closed")

# 1.G  2. M

readBlobData(1)
The above code works well in the folder in which it was created. But when I transfer it to another folder for making and run it I get the following output:
Connected to SQLite
Failed to read blob data from sqlite table no such table: new_employee
sqlite connection is closed
Reply


Messages In This Thread
.exe prob - by Kundan - Nov-05-2020, 05:10 AM
RE: .exe prob - by ndc85430 - Nov-05-2020, 05:17 AM
RE: .exe prob - by Kundan - Nov-06-2020, 04:54 AM
RE: .exe prob - by Kundan - Nov-06-2020, 04:56 AM
RE: .exe prob - by ndc85430 - Nov-06-2020, 05:26 AM
RE: .exe prob - by Kundan - Nov-07-2020, 03:39 AM
RE: .exe prob - by ndc85430 - Nov-07-2020, 05:26 AM
RE: .exe prob - by Kundan - Nov-09-2020, 04:14 AM
RE: .exe prob - by ndc85430 - Nov-09-2020, 05:34 AM
RE: .exe prob - by Kundan - Nov-12-2020, 05:12 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Newbie prob Snakecharmer 3 27,523 Jan-29-2019, 10:04 PM
Last Post: Snakecharmer

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020