Portál AbcLinuxu, 7. května 2025 01:06
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(Id): try: sqliteConnection = sqlite3.connect('thumbnails_digikam.db') cursor = sqliteConnection.cursor() print("Connected to SQLite") sql_fetch_blob_query = """SELECT * from Thumbnails where id = ?""" # sql_fetch_blob_query = """SELECT * from Thumbnails where id = 23""" cursor.execute(sql_fetch_blob_query, (Id,)) record = cursor.fetchall() for row in record: print("Id = ", row[0],) photo = row[4] print("Storing image on disk \n") photoPath = "/home/q1/Pictures/thumbnails/" + name + ".jpg" 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") readBlobData(23) readBlobData(24)Bohuzel ale Python hlasi ze dotycna tabulka v db neni. Jenze ona tam JE, SQLiteBrowser ji zobrazuje a dotaz "SELECT * from Thumbnails where id = 23" v ni normalne funguje. Nebude neco s opravnenimi? Nebo co jineho je spatne? Predem dekuji za pripadne tipy.
q1@zzz:~/Pictures$ python3 blob_viewer.py Connected to SQLite Failed to read blob data from sqlite table no such table: Thumbnails sqlite connection is closed Connected to SQLite Failed to read blob data from sqlite table no such table: Thumbnails sqlite connection is closed
Řešení dotazu:
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.