title: How to save a image file on a Postgres database?
body: <p>For learning purposes, I'm creating a site using Python+Flask. I want to recover an image from database and show it on screen. But one step at a time.</p>
  
  <p>I have no idea how to save an image in my database in the first place. My searches only revealed that I have to use a <code>bytea</code> type in my database. Then I get my image and somehow (??) convert it to an array of bytes (bytea == array of bites?) and somehow (??) use this array in a insert command.</p>
  
  <p>I was able to discover (maybe) how to do it in Java (<a href="http://jeebestpractices.blogspot.com.br/2011/03/save-images-into-database-postgres-with.html" rel="noreferrer">here</a>) and C# (<a href="https://stackoverflow.com/questions/4852558/how-to-save-image-to-a-database">here</a>), but I would really like to use Python, at least for now.</p>
  
  <p>Can someone help me?</p>
  
  <p>There are tons of questions of this kind in this site. But most (easily over 85%) of them are replied as "You shouldn't save images in your database, they belong in fs" and fail to answer the question. The rest don't quite solve my problem. So please don't mark this as duplicate if the duplicate has this kind of answer.</p>