May-14-2020, 09:08 PM
I have this sqlite3 database table in the server side that contains a BLOB object:
Server-side:
q_conn = sqlite3.connect('questions_stack.db') q_c = q_conn.cursor() q_c.execute("""CREATE TABLE IF NOT EXISTS questions ( id INTEGER PRIMARY KEY, topic TEXT, username TEXT, likes INTEGER, pic BLOB) """)[/align] The client sends an image file in pieces by opening it 'rb': [align=justify]f = open(pic_path, "rb") l = f.read(1024) while l: client_socket.send(l) l = f.read(1024) client_socket.send("stop")[/align] and the server saves the image as post_pic file, and inserts the image object by opening it as 'wb' to the database column pic BLOB: [align=justify]f = open('post_pic'+".jpg", 'wb') # open in binary l = client.recv(1024) while l != "stop" and l != "nopic": f.write(l) l = client.recv(1024) f.close()I tried sending the table questions data to the client (so he could create a GUI) using pickle module:
Server-side:
q_conn = sqlite3.connect('questions_stack.db') q_conn.text_factory = str q_c = q_conn.cursor() q_c.execute("SELECT * FROM questions") feed = q_c.fetchall() data = pickle.dumps(feed) q_conn.close() client.send(data)Client side:
d = client_socket.recv(BUFSIZ) feed = pickle.loads(d)However, I got this error on the client-side:
Error:feed = pickle.loads(d)
raise ValueError, "insecure string pickle"
ValueError: insecure string pickle
Do you have any idea what the problem is? and how can I fix it? I'd really appreciate it if you could help me!