change location of .sqlite_history file
Clash Royale CLAN TAG#URR8PPP
up vote
4
down vote
favorite
sqlite3
stores command history in .sqlite_history
, which is by default created in:
$HOME/.sqlite_history
How can I change this location to somewhere else?
This is possible for example with mysql
, where I can define environment variable
MYSQL_HISTFILE=/path/to/whatever/file
But I could not find any corresponding environment variable for sqlite3
export SQLITE_HISTFILE=/tmp/history
has no effect. I found a post where somebody asks same question, but no useful answers are given.
environment-variables home sqlite
add a comment |
up vote
4
down vote
favorite
sqlite3
stores command history in .sqlite_history
, which is by default created in:
$HOME/.sqlite_history
How can I change this location to somewhere else?
This is possible for example with mysql
, where I can define environment variable
MYSQL_HISTFILE=/path/to/whatever/file
But I could not find any corresponding environment variable for sqlite3
export SQLITE_HISTFILE=/tmp/history
has no effect. I found a post where somebody asks same question, but no useful answers are given.
environment-variables home sqlite
1
Request was made to the project at sqlite.1065341.n5.nabble.com/…
– Ben Creasy
Sep 12 '16 at 7:45
add a comment |
up vote
4
down vote
favorite
up vote
4
down vote
favorite
sqlite3
stores command history in .sqlite_history
, which is by default created in:
$HOME/.sqlite_history
How can I change this location to somewhere else?
This is possible for example with mysql
, where I can define environment variable
MYSQL_HISTFILE=/path/to/whatever/file
But I could not find any corresponding environment variable for sqlite3
export SQLITE_HISTFILE=/tmp/history
has no effect. I found a post where somebody asks same question, but no useful answers are given.
environment-variables home sqlite
sqlite3
stores command history in .sqlite_history
, which is by default created in:
$HOME/.sqlite_history
How can I change this location to somewhere else?
This is possible for example with mysql
, where I can define environment variable
MYSQL_HISTFILE=/path/to/whatever/file
But I could not find any corresponding environment variable for sqlite3
export SQLITE_HISTFILE=/tmp/history
has no effect. I found a post where somebody asks same question, but no useful answers are given.
environment-variables home sqlite
environment-variables home sqlite
edited Aug 31 '16 at 6:32
Rahul
8,84412842
8,84412842
asked Aug 31 '16 at 6:28
Martin Vegter
62934117234
62934117234
1
Request was made to the project at sqlite.1065341.n5.nabble.com/…
– Ben Creasy
Sep 12 '16 at 7:45
add a comment |
1
Request was made to the project at sqlite.1065341.n5.nabble.com/…
– Ben Creasy
Sep 12 '16 at 7:45
1
1
Request was made to the project at sqlite.1065341.n5.nabble.com/…
– Ben Creasy
Sep 12 '16 at 7:45
Request was made to the project at sqlite.1065341.n5.nabble.com/…
– Ben Creasy
Sep 12 '16 at 7:45
add a comment |
3 Answers
3
active
oldest
votes
up vote
5
down vote
accepted
It looks like it's hardcoded in line 5576 in shell.c (version 3.14.1):
sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
So, to change it, your only option is to edit the source and recompile.
add a comment |
up vote
3
down vote
To list some of the possible alternatives,
make
~/.sqlite_history
into a symbolic link to another file.simply run
HOME=/tmp sqlite3
to have the program save the history in/tmp/.sqlite_history
, though this assumes you don't need the real home directory inside the command environment.edit the binary and replace the string
"%s/.sqlite_history"
, found by Hoov, by another string with the same number of bytes, eg"/tmp/sqlitehistory"
:sed < /usr/bin/sqlite3 's|%s/.sqlite_history|/tmp/sqlitehistory|' >/tmp/sqlite3
cmp -l /usr/bin/sqlite3 /tmp/sqlite3 # check no extraneous differences
chmod +x /tmp/sqlite3
/tmp/sqlite3use the
LD_PRELOAD
shim I proposed in an another question to change one filename ("/tmp/adb.log"
in that case) to another during anopen()
call.
Excellent and enlightening answer. I feel ignorant now.
– Hoov
Sep 2 '16 at 7:36
But in reality, when this situation arises, I usually prefer to follow your answer and rebuild from sources, unless this proves to be too tedious, with too many dependencies etc.
– meuh
Sep 2 '16 at 7:53
Yes, it think it's the most manageable solution, but your solution three could come in handy when you don't have the source. Saved it to a script.
– Hoov
Sep 2 '16 at 8:07
Note that in sqlite's case, setting$HOME
will not work, since sqlite does not honour that environment variable: it uses only whatgetpwuid()
returns (e.g. from/etc/passwd
).
– ayekat
Aug 31 '17 at 5:58
add a comment |
up vote
1
down vote
As of Oct 10, 2018 it appears that a new variable, $SQLITE_HISTORY
, was added to address this.
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
5
down vote
accepted
It looks like it's hardcoded in line 5576 in shell.c (version 3.14.1):
sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
So, to change it, your only option is to edit the source and recompile.
add a comment |
up vote
5
down vote
accepted
It looks like it's hardcoded in line 5576 in shell.c (version 3.14.1):
sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
So, to change it, your only option is to edit the source and recompile.
add a comment |
up vote
5
down vote
accepted
up vote
5
down vote
accepted
It looks like it's hardcoded in line 5576 in shell.c (version 3.14.1):
sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
So, to change it, your only option is to edit the source and recompile.
It looks like it's hardcoded in line 5576 in shell.c (version 3.14.1):
sqlite3_snprintf(nHistory, zHistory,"%s/.sqlite_history", zHome);
So, to change it, your only option is to edit the source and recompile.
edited Aug 31 '16 at 7:52
answered Aug 31 '16 at 7:44
Hoov
57838
57838
add a comment |
add a comment |
up vote
3
down vote
To list some of the possible alternatives,
make
~/.sqlite_history
into a symbolic link to another file.simply run
HOME=/tmp sqlite3
to have the program save the history in/tmp/.sqlite_history
, though this assumes you don't need the real home directory inside the command environment.edit the binary and replace the string
"%s/.sqlite_history"
, found by Hoov, by another string with the same number of bytes, eg"/tmp/sqlitehistory"
:sed < /usr/bin/sqlite3 's|%s/.sqlite_history|/tmp/sqlitehistory|' >/tmp/sqlite3
cmp -l /usr/bin/sqlite3 /tmp/sqlite3 # check no extraneous differences
chmod +x /tmp/sqlite3
/tmp/sqlite3use the
LD_PRELOAD
shim I proposed in an another question to change one filename ("/tmp/adb.log"
in that case) to another during anopen()
call.
Excellent and enlightening answer. I feel ignorant now.
– Hoov
Sep 2 '16 at 7:36
But in reality, when this situation arises, I usually prefer to follow your answer and rebuild from sources, unless this proves to be too tedious, with too many dependencies etc.
– meuh
Sep 2 '16 at 7:53
Yes, it think it's the most manageable solution, but your solution three could come in handy when you don't have the source. Saved it to a script.
– Hoov
Sep 2 '16 at 8:07
Note that in sqlite's case, setting$HOME
will not work, since sqlite does not honour that environment variable: it uses only whatgetpwuid()
returns (e.g. from/etc/passwd
).
– ayekat
Aug 31 '17 at 5:58
add a comment |
up vote
3
down vote
To list some of the possible alternatives,
make
~/.sqlite_history
into a symbolic link to another file.simply run
HOME=/tmp sqlite3
to have the program save the history in/tmp/.sqlite_history
, though this assumes you don't need the real home directory inside the command environment.edit the binary and replace the string
"%s/.sqlite_history"
, found by Hoov, by another string with the same number of bytes, eg"/tmp/sqlitehistory"
:sed < /usr/bin/sqlite3 's|%s/.sqlite_history|/tmp/sqlitehistory|' >/tmp/sqlite3
cmp -l /usr/bin/sqlite3 /tmp/sqlite3 # check no extraneous differences
chmod +x /tmp/sqlite3
/tmp/sqlite3use the
LD_PRELOAD
shim I proposed in an another question to change one filename ("/tmp/adb.log"
in that case) to another during anopen()
call.
Excellent and enlightening answer. I feel ignorant now.
– Hoov
Sep 2 '16 at 7:36
But in reality, when this situation arises, I usually prefer to follow your answer and rebuild from sources, unless this proves to be too tedious, with too many dependencies etc.
– meuh
Sep 2 '16 at 7:53
Yes, it think it's the most manageable solution, but your solution three could come in handy when you don't have the source. Saved it to a script.
– Hoov
Sep 2 '16 at 8:07
Note that in sqlite's case, setting$HOME
will not work, since sqlite does not honour that environment variable: it uses only whatgetpwuid()
returns (e.g. from/etc/passwd
).
– ayekat
Aug 31 '17 at 5:58
add a comment |
up vote
3
down vote
up vote
3
down vote
To list some of the possible alternatives,
make
~/.sqlite_history
into a symbolic link to another file.simply run
HOME=/tmp sqlite3
to have the program save the history in/tmp/.sqlite_history
, though this assumes you don't need the real home directory inside the command environment.edit the binary and replace the string
"%s/.sqlite_history"
, found by Hoov, by another string with the same number of bytes, eg"/tmp/sqlitehistory"
:sed < /usr/bin/sqlite3 's|%s/.sqlite_history|/tmp/sqlitehistory|' >/tmp/sqlite3
cmp -l /usr/bin/sqlite3 /tmp/sqlite3 # check no extraneous differences
chmod +x /tmp/sqlite3
/tmp/sqlite3use the
LD_PRELOAD
shim I proposed in an another question to change one filename ("/tmp/adb.log"
in that case) to another during anopen()
call.
To list some of the possible alternatives,
make
~/.sqlite_history
into a symbolic link to another file.simply run
HOME=/tmp sqlite3
to have the program save the history in/tmp/.sqlite_history
, though this assumes you don't need the real home directory inside the command environment.edit the binary and replace the string
"%s/.sqlite_history"
, found by Hoov, by another string with the same number of bytes, eg"/tmp/sqlitehistory"
:sed < /usr/bin/sqlite3 's|%s/.sqlite_history|/tmp/sqlitehistory|' >/tmp/sqlite3
cmp -l /usr/bin/sqlite3 /tmp/sqlite3 # check no extraneous differences
chmod +x /tmp/sqlite3
/tmp/sqlite3use the
LD_PRELOAD
shim I proposed in an another question to change one filename ("/tmp/adb.log"
in that case) to another during anopen()
call.
edited Apr 13 '17 at 12:36
Community♦
1
1
answered Aug 31 '16 at 12:35
meuh
31.1k11754
31.1k11754
Excellent and enlightening answer. I feel ignorant now.
– Hoov
Sep 2 '16 at 7:36
But in reality, when this situation arises, I usually prefer to follow your answer and rebuild from sources, unless this proves to be too tedious, with too many dependencies etc.
– meuh
Sep 2 '16 at 7:53
Yes, it think it's the most manageable solution, but your solution three could come in handy when you don't have the source. Saved it to a script.
– Hoov
Sep 2 '16 at 8:07
Note that in sqlite's case, setting$HOME
will not work, since sqlite does not honour that environment variable: it uses only whatgetpwuid()
returns (e.g. from/etc/passwd
).
– ayekat
Aug 31 '17 at 5:58
add a comment |
Excellent and enlightening answer. I feel ignorant now.
– Hoov
Sep 2 '16 at 7:36
But in reality, when this situation arises, I usually prefer to follow your answer and rebuild from sources, unless this proves to be too tedious, with too many dependencies etc.
– meuh
Sep 2 '16 at 7:53
Yes, it think it's the most manageable solution, but your solution three could come in handy when you don't have the source. Saved it to a script.
– Hoov
Sep 2 '16 at 8:07
Note that in sqlite's case, setting$HOME
will not work, since sqlite does not honour that environment variable: it uses only whatgetpwuid()
returns (e.g. from/etc/passwd
).
– ayekat
Aug 31 '17 at 5:58
Excellent and enlightening answer. I feel ignorant now.
– Hoov
Sep 2 '16 at 7:36
Excellent and enlightening answer. I feel ignorant now.
– Hoov
Sep 2 '16 at 7:36
But in reality, when this situation arises, I usually prefer to follow your answer and rebuild from sources, unless this proves to be too tedious, with too many dependencies etc.
– meuh
Sep 2 '16 at 7:53
But in reality, when this situation arises, I usually prefer to follow your answer and rebuild from sources, unless this proves to be too tedious, with too many dependencies etc.
– meuh
Sep 2 '16 at 7:53
Yes, it think it's the most manageable solution, but your solution three could come in handy when you don't have the source. Saved it to a script.
– Hoov
Sep 2 '16 at 8:07
Yes, it think it's the most manageable solution, but your solution three could come in handy when you don't have the source. Saved it to a script.
– Hoov
Sep 2 '16 at 8:07
Note that in sqlite's case, setting
$HOME
will not work, since sqlite does not honour that environment variable: it uses only what getpwuid()
returns (e.g. from /etc/passwd
).– ayekat
Aug 31 '17 at 5:58
Note that in sqlite's case, setting
$HOME
will not work, since sqlite does not honour that environment variable: it uses only what getpwuid()
returns (e.g. from /etc/passwd
).– ayekat
Aug 31 '17 at 5:58
add a comment |
up vote
1
down vote
As of Oct 10, 2018 it appears that a new variable, $SQLITE_HISTORY
, was added to address this.
add a comment |
up vote
1
down vote
As of Oct 10, 2018 it appears that a new variable, $SQLITE_HISTORY
, was added to address this.
add a comment |
up vote
1
down vote
up vote
1
down vote
As of Oct 10, 2018 it appears that a new variable, $SQLITE_HISTORY
, was added to address this.
As of Oct 10, 2018 it appears that a new variable, $SQLITE_HISTORY
, was added to address this.
answered Nov 26 at 3:14
mattmc3
1113
1113
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f306890%2fchange-location-of-sqlite-history-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Request was made to the project at sqlite.1065341.n5.nabble.com/…
– Ben Creasy
Sep 12 '16 at 7:45