Hi - we have a crashed Openerp 7 db adn where trying to extract a pdf file from ir_attachment.dbdatas
I have tried directly via SQL but although I can retrieve something it appears to be "Gobbledygook!!
Is there a way of extracting files from the db?
copy (SELECT db_datas FROM ir_attachment WHERE name='Invoice_SAJ_2016_0964_.pdf') to '/tmp/Invoice.pdf' (FORMAT "binary");
Any advice please.
If I open each file in a text editor each file starts with "PGCOPY" - a clue maybe?
This is my reHASH of Sir 'Jaime Vasquez' above code, I tried converting his comment to an answer but kept failing.
Jaime, please forgive my poor rehash of your coding, I'm still in the "Jowels flapping in the wind, vertical acceleration learning phase" :)
conn = psycopg2.connect ("host='"+host+"' port= '"+port+"' dbname= '"+dbname+"' user= '"+user+"' password= '"+password+"'")
cur = conn.cursor()
print "Unable to connect to database."
#Invoice range to extract
for Invoice in range (768,967):
SearchString = "SELECT a.name, description, a.create_date, a.datas_fname, a.id, a.db_datas FROM ir_attachment a WHERE a.datas_fname = '"+"INVSAJ20160"+str(Invoice)+".pdf.pdf"+"';"
rows = cur.fetchall()
#Save Invocies to file
for row in rows:
f= open('C:\Users\Me\Documents\Invoices\INVSAJ20160'+str(Invoice)+'.pdf', 'wb')
#We have to decode first
if __name__ == '__main__':
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
About This Community
|Asked: 8/18/16, 8:49 AM|
|Seen: 309 times|
|Last updated: 8/23/16, 9:53 AM|