title: cant upload to datastore in ckan 2.5.1: using postgres user instead of configured one
body: <p>I followed the instructions to install ckan as a package on Ubuntu 12.04 LTS. </p>
  
  <p>I also configured the datastore extension. The databases have been created and the default users and passwords have been configured in /etc/ckan/default/production.ini</p>
  
  <p>My problem is that every time I want to upload a dataset to the DataStore (using the button "Upload to DataStore") it first seems that everything works fine. But if I click somewhere else and click on the DataStore again I get the following red error box:</p>
  
  <blockquote>
    <p>Error: CKAN DataStore bad response. Status code: 409 Conflict. At:
    <a href="http://xubuntu12ltsckan/api/3/action/datastore_create" rel="nofollow">http://xubuntu12ltsckan/api/3/action/datastore_create</a>. HTTP status
    code: 409 Response: {"help":
    "<a href="http://xubuntu12ltsckan/api/3/action/help_show?name=datastore_create" rel="nofollow">http://xubuntu12ltsckan/api/3/action/help_show?name=datastore_create</a>",
    "success": false, "error": {"fields": ["\"2016-01-07 14:35:12 ERROR :
    Error connecting to the server: FATAL: password... Requested URL:
    hhttp://xubuntu12ltsckan/api/3/action/datastore_create</p>
  </blockquote>
  
  <p>(Third url mangled because I don't have the reputation to post more than 2 URLs) </p>
  
  <p>The /var/log/apache2/datapusher.error.log lists these lines:</p>
  
  <pre><code>Fri Jan 22 13:38:24 2016] [error] /usr/lib/ckan/datapusher/lib/python2.7/site-packages/sqlalchemy/sql/sqltypes.py:185: SAWarning: Unicode type received non-unicode bind param value '42e50497-2231-4c86-b8db-d...'. (this warning may be suppressed after 10 occurrences)
  [Fri Jan 22 13:38:24 2016] [error]   (util.ellipses_string(value),))
  [Fri Jan 22 13:38:24 2016] [error] Fetching from: http://xubuntu12ltsckan/dataset/f4f9e859-fa6a-4257-8727-32358b448864/resource/d938a82f-95f7-4abd-b982-b32174dfa584/download/pgadmin.log
  [Fri Jan 22 13:38:24 2016] [error] Deleting "d938a82f-95f7-4abd-b982-b32174dfa584" from datastore.
  [Fri Jan 22 13:38:24 2016] [error] Determined headers and types: [{'type': u'text', 'id': u'2016-01-07 14:35:12 ERROR  : Error connecting to the server: FATAL:  password authentication failed for user "postgres"'}]
  [Fri Jan 22 13:38:24 2016] [error] Saving chunk 0
  [Fri Jan 22 13:38:24 2016] [error] Job "push_to_datastore (trigger: RunTriggerNow, run = True, next run at: None)" raised an exception
  [Fri Jan 22 13:38:24 2016] [error] Traceback (most recent call last):
  [Fri Jan 22 13:38:24 2016] [error]   File "/usr/lib/ckan/datapusher/lib/python2.7/site-packages/apscheduler/scheduler.py", line 512, in _run_job
  [Fri Jan 22 13:38:24 2016] [error]     retval = job.func(*job.args, **job.kwargs)
  [Fri Jan 22 13:38:24 2016] [error]   File "/usr/lib/ckan/datapusher/src/datapusher/datapusher/jobs.py", line 387, in push_to_datastore
  [Fri Jan 22 13:38:24 2016] [error]     records, api_key, ckan_url)
  [Fri Jan 22 13:38:24 2016] [error]   File "/usr/lib/ckan/datapusher/src/datapusher/datapusher/jobs.py", line 203, in send_resource_to_datastore
  [Fri Jan 22 13:38:24 2016] [error]     check_response(r, url, 'CKAN DataStore')
  [Fri Jan 22 13:38:24 2016] [error]   File "/usr/lib/ckan/datapusher/src/datapusher/datapusher/jobs.py", line 137, in check_response
  [Fri Jan 22 13:38:24 2016] [error]     request_url=request_url, response=response.text)
  [Fri Jan 22 13:38:24 2016] [error] HTTPError
  </code></pre>
  
  <p>So my problem is that for some reason I don't know ckan tries to connect to the postgres database with the postgres user.</p>
  
  <p>My production.ini instead looks like this:</p>
  
  <pre><code>## Database Settings
  sqlalchemy.url = postgresql://ckan_default:xxx@localhost/ckan_default
  
  ckan.datastore.write_url = postgresql://ckan_default:xxx@localhost/datastore_default
  ckan.datastore.read_url = postgresql://datastore_default:xxx@localhost/datastore_default
  </code></pre>
  
  <p>There is no reference to the default database admin user in this file. The role "ckan_default" has CREATE/TEMP/CONNECT privileges and "datastore_default" has CONNECT privileges on the datastore_default database.</p>
  
  <p>I don't see any access constraints here. Can somebody help me to solve this issue?</p>