title: Using Python to upload a binary file to a postgres server
body: <p>I am trying to upload a binary file to a postgres server. I think I correctly modified a Python script (<a href="https://gist.github.com/illume/8aa7c2d03273da846bf4361236a4f3f9#file-image_save-py" rel="nofollow noreferrer">https://gist.github.com/illume/8aa7c2d03273da846bf4361236a4f3f9#file-image_save-py</a>) so that it will connect to my postgres server, but I am stuck trying to invoke the script in the command line.  From what I understand, I need to navigate to the directory where I have the image_save.py script and call it.  I also put a test file in the same directory, so I attempted to execute:</p>
  
  <pre><code>python image_save.py shuttle.jpg
  </code></pre>
  
  <p>For which I got this error: "error: one of the arguments --store --fetch is required."</p>
  
  <p>I then tried:</p>
  
  <pre><code>python image_save.py --store shuttle.jpg
  </code></pre>
  
  <p>I got:</p>
  
  <pre><code>  Traceback (most recent call last):
    File "image_save.py", line 45, in &lt;module&gt;
      main(sys.argv)
    File "image_save.py", line 30, in main
      curs.execute("INSERT INTO files(id, orig_filename, file_data) VALUES (DEFAULT,%s,%s) RETURNING id", (args.filename, filedata))
  ValueError: A string literal cannot contain NUL (0x00) characters.
  </code></pre>
  
  <p>I also tried:</p>
  
  <pre><code>python -m image_save.py shuttle.jpg
  </code></pre>
  
  <p>And I got "C:\Python27\python.exe: No module named image_save.py"</p>
  
  <p>I really think I am just invoking the script incorrectly.  Can anyone see what I am doing wrong?</p>