I have this sqlite3 database table in the server side that contains a BLOB object:
I tried sending the table questions data to the client (so he could create a GUI) using pickle module:
Server-side:
Client side:
However, I got this error on the client-side:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
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() |
Server-side:
1 2 3 4 5 6 7 8 |
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) |
1 2 |
d = client_socket.recv(BUFSIZ) feed = pickle.loads(d) |
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!