title: how to post data and binary data using urllib2 in python
body: <p>I essentially want to do this:</p>
  
  <pre><code>curl -X POST "http://URL?u=user&amp;p=password" --data-binary @myconfig.json
  </code></pre>
  
  <p>with urllib2.</p>
  
  <p>I found examples for sending just the user and password, or just the binary, but not both at the same time, and some contradict each other.</p>
  
  <p>I am doing this to create an influxdb with a retention policy based on instructions here:</p>
  
  <p><a href="https://docs.influxdata.com/influxdb/v0.8/advanced_topics/sharding_and_storage/" rel="nofollow">https://docs.influxdata.com/influxdb/v0.8/advanced_topics/sharding_and_storage/</a></p>
  
  <pre><code>curl -X POST "http://localhost:8086/cluster/database_configs/mydb?u=root&amp;p=root" --data-binary @myconfig.json
  </code></pre>
  
  <p>Thanks!</p>