Jay Taylor's notes

back to listing index

sqlite - Avoid message "-​- Loading resources from .sqliterc" - Stack Overflow

[web search]
Original source (stackoverflow.com)
Tags: bash howto shell-scripting sqlite stackoverflow.com
Clipped on: 2022-07-22

  1. Home
    1. Public
    2. Questions
    3. Tags
    4. Users
    5. Companies
    6. Collectives
    7. Explore Collectives
    1. Teams
      Stack Overflow for Teams – Start collaborating and sharing organizational knowledge. Image (Asset 1/10) alt=

      Minor problem, nevertheless irritating : Is there a way to avoid the following message from appearing each time I make a query :

      -- Loading resources from /Users/ThG/.sqliterc

      Image (Asset 2/10) alt=

      As a stupid workaround, this works:

      <. sqlite your_sqlite.db 'select * from your_table'
      

      This is because the current code does this:

       if( stdin_is_interactive ){
         utf8_printf(stderr,"-- Loading resources from %sn",sqliterc);
       }
      

      Forcing a stdin redirect thwarts this due to this piece of code:

      stdin_is_interactive = isatty(0);
      

      This works as well:

      sqlite -batch your_sqlite.db 'select * from your_table'
      

      due to this piece of code:

      }else if( strcmp(z,"-batch")==0 ){
        /* Need to check for batch mode here to so we can avoid printing
        ** informational messages (like from process_sqliterc) before
        ** we do the actual processing of arguments later in a second pass.
        */
        stdin_is_interactive = 0;
      }
      

      but it's longer, so kind of defeats the purpose.

      answered Sep 27, 2018 at 19:59
      Image (Asset 3/10) alt=
      Unlike some other answers, this not only solves the problem, but respects the fact that some of us do like to have an .sqliterc for a reason, instead of assuming "bah who works in a shell anyway"
      – cryptarch
      Sep 8, 2020 at 7:46
      3

      I know that this question is PRETTY old now, but simply deleting '/Users/ThG/.sqliterc' should solve the problem. '.sqliterc' is a configuration file for sqlite's interactive command line front-end. If you don't spend a lot of time in there, you won't miss the file.

      answered Sep 23, 2011 at 21:26
      Image (Asset 4/10) alt=
      Thank you for the answer. In fact, I use the command line front-end. I suppose this means I shall have to put up with it...
      – ThG
      Sep 24, 2011 at 9:47
      2

      That resource msg comes out on stderr, and it's followed by a blank line, so you could get rid of it with something like this (wrapped up in a script file of its own):

      #!/bin/bash
      sqlite3 -init /your/init/file /your/sqlite3/file.db "
          your
          SQL
          cmds
      " 2>/dev/null | sed -e1d
      
      answered Mar 8, 2014 at 14:13
      Image (Asset 5/10) alt=

      A bit late but @levant pied almost had the solution, you need to pass an additional -interactive to silence the --loading resources from.

      $ sqlite3 -batch -interactive
      SQLite version 3.31.1 2020-01-27 19:55:54
      Enter ".help" for usage hints.
      sqlite> .q
      
      answered Feb 3, 2020 at 5:08
      Image (Asset 6/10) alt=

      You can simply rename your config file to disable the warning. And revert the rename to keep the configuration after use.

      I use the following:

      #suppress default configuration warnings
      mv $HOME/.sqliterc $HOME/.backup.sqliterc 
      
      # sqlite3 scripts...
      
      #revert
      mv $HOME/.backup.sqliterc $HOME/.sqliterc
      
      answered Aug 23, 2019 at 16:31
      Image (Asset 7/10) alt=

      When using sqlite in shell scripts, you usually don't event want your ~/.sqliterc to be loaded at all. This works well for me:

      sqlite3 -init <(echo)
      

      Explanation:

      • -init specifies the file to load instead of ~/.sqliterc.
      • <(echo) uses Process Substitution to provide a path to a temporary empty file.
      answered Feb 4, 2021 at 11:55
      Image (Asset 8/10) alt=
      This does not work, now I see a -- Loading resources from /dev/fd/63. Aug 4, 2021 at 11:25
    2. @user1461607 And /dev/fd/63 is empty, so your ~/.sqliterc is not loaded. Oct 19, 2021 at 9:18
    3. 0
      This post is hidden. It was deleted 10 years ago by the post author.

      sqlite3 will load ~/.sqliterc, if it exists!

      If you don't want it, just rm it.

      rm /Users/ThG/.sqliterc
      

      If you find yourself keep typing sqlite3 -header -column xxx.db.

      You can put those dot-options in ~/.sqliterc to save some typing:

      .header on
      .mode column
      
      answered May 7, 2011 at 5:47
      Love this site?

      Get the weekly newsletter! In it, you'll get:

      • The week's top questions and answers
      • Important community announcements
      • Questions that need answers

      see an example newsletter

      Hot Network Questions