title: How to import a JSON file to PostgreSQL database in BASH
body: <p>I'm working on a bash script and I need to import a JSON file into my Postgres database. This JSON file is really big and I have tried diferents ways but all of this didn´t work.
  I can´t post a example of the JSON file because it is really big (like 15Mb)</p>
  
  <p>Using a bash variable to store the data: </p>
  
  <pre><code>VAR=$(cat cucumber.json.1)
  su -c "psql -A -t -d tareas -c \"insert into consulta (url, identificador, fecha, artefacto) values ('UNKNOWN', $identificadorBBDD, '$diaBBDD', :'$VAR')\"" postgres 
  </code></pre>
  
  <p>It returns that the list of the arguments is too long, I think is because when is reading the variable, the command thinks that the variable just finish and it breaks the structure of the query.</p>
  
  <p>I tried to use the function in postgres lo_import but I got the same result.</p>
  
  <p>I used a postgres command to store the data but it didn´t work:</p>
  
  <pre><code>\set content `cat cucumber.json.1` create temp table t ( j json); insert into t values(:'content');
  </code></pre>
  
  <p>Thanks for your help.</p>