Undetected table
(1) By prkundan on 2020-11-12 05:30:21 [link] [source]
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
(2) By Keith Medcalf (kmedcalf) on 2020-11-12 06:36:35 in reply to 1 [source]
Sounds like you forgot to transfer the database.