I cannot find the command history created by sqlite3.
I have both Windows and Cygwin version.
Using the Windows binary, I can use up/down arrow to see previous commands, even from previous runs of command. But I can't find the file .sqlite_history. This answer suggests it should be in the home directory, but I can't find it there. I do have working a .sqliterc so I know it is the correct directory.
Using the Cygwin binary, I can't get the history to work at all. It seems history is not saved at all?
On the documentation page I cannot find any mention of history at all.
For Windows console programs, the command history is handled by the Windows console itself. There are separate history buffers for different programs and different console sessions, and these buffers are not stored anywhere by default. However, you can use the doskey tool to manage them manually.
Cygwin uses Windows pipes to emulate the Unix tty devices; this often results in programs not detecting that they are running in a console. Try running the program both from within the Cygwin shell and from the Windows shell.
The SQLITE_HISTORY environment variable, if it exists, specifies
the name of the command-line editing history file
To repeat the last command, just press the ↑ key, to search for older
ones — use Ctrl+R shortcut. History search It's faster to find a query than to type it again
By default, SQLite stores the history file in the user’s home directory
and names it .sqlite_history It’s in plain text, so you can view it
in your favorite editor. If you prefer to save it elsewhere, specify
the full path in the SQLITE_HISTORY environment variable.
source: https://antonz.org/sqlite-history
e.g:
cd ~
nano .sqlite_history
Related
I am trying to start out using Notepad++ to run SQLite commands. I have tried following two brief YouTube tutorials to get me going. I can run the initial .bat file, but still cannot run the .sql file.
I have a Windows system environment Path variable set to the folder containing sqlite3.exe
"C:\Users\Adam\sqlite\"
I have saved the following file RunSQLite.bat in the folder containing sqlite3.exe
sqlite3.exe testDB.db
I have created a second file queries.sql
SELECT 34;
When I try to run queries.sql from Notepad++, using the RUN command:
C:\Users\Adam\sqlite\RunSQLite.bat "$(FULL_CURRENT_PATH)"
the only file that appears to run is RunSQLite.bat, giving the output:
SQLite version 3.36.0 2021-06-18 18:36:39
Enter ".help" for usage hints.
sqlite>
Can anyone tell where I have gone wrong?
Thanks in advance.
aphopk
This C:\Users\Adam\sqlite\RunSQLite.bat "$(FULL_CURRENT_PATH)" will do exactly the same thing if run at the shell. RunSQLite.bat does not take any arguments so the Run command in npp is working as expected.
sqlite3 takes input from an external file with the .read command.
Path issues notwithstanding a bat file something like this should accomplish the task:
sqlite3.exe testDB.db ".read %1"
Notepad++ is a text editor, so you can now use it to edit your SQL file. After selecting the Language > SQL, Notepad++ will highlight SQL syntax as you type. Try typing some SQL, like
SELECT "Hi";
SELECT * FROM mydatabase WHERE id LIKE 'ID%';
You will see color, bold, and other possible formatting applied to the text you type. If you save the file as something.sql, and then load something.sql in your SQL client, the client will run the SQL commands from that file. If you have an existing somethingElse.sql file, you can open it in Notepad++, which will auto-recognize that it’s SQL and apply the syntax highlighting, allowing you to edit it and save it.
By using the Run > Run dialog, you can run an arbitrary command. For example, if your SQL client has a command-line mode accessed thru sqlclient.exe, you could type
c:\path\to\sqlclient.exe $(FILE_NAME)
If you just run it, that probably won’t show you any results… but if you ran
cmd /k c:\path\to\sqlclient.exe $(FILE_NAME)
It will open a new cmd.exe Windows command prompt, and show the output from that file.
If instead of running, you hit “SAVE”, you can give it a name (which will end up later in the Run menu), and/or a keyboard shortcut, so that you can easily re-use that many times.
If you want to do something more fancy, use the NppExec plugin, which includes a better batch/scripting language. Once again, you can save the NppExec script, and make it show up in the Macro menu.
If Python is a programming language you know or could learn (or if, like me, you know enough other programming languages that you can fake the Python), then the Python Script plugin will allow you to do even fancier stuff. (Python is a complete programming language, and has many libraries written, which could act as an interface between your SQL source file and your database engine; PythonScript has access to a full python2.7 interpreter. For example, you could write a script in Python which executes the commands from your SQL, grabs the results from your database engine, and displays them in Notepad++, either inline with your original SQL code, or in a new text document. You are really limited only by your imagination and knowledge of Python.)
I'd like to edit a sqlite script in an emacs buffer. I wonder how to run this script(or buffer) from emacs.
Any good idea for this? Thanks.
sqlite is supported out of box in the built-in sql-mode that is automatically enabled for files with .sql extension. You can press M-x sql-sqlite to get access to your sqlite database.
After that you can use commands like C-c C-r to send the region to interpreter and see the results (there are also other commands like send paragraph, send buffer, etc. - see them in the SQL menu.
EmacsWiki has a page about this mode where you can find more recipes, etc.
We have a legacy system whose code files are stored in a proprietary (binary) format.
You cannot modify them unless:
You use the proprietary editor, which is awful
You export the code to a text file, do your changes using any text editor, then import the code back to it's original format. Any attempt to modify the binary files outside the official editor will corrupt them.
Also, any developer who want to work on the code in their Windows machines must:
Log into their unix account through terminal.
Use a shell script to convert the binary to text.
Download the text file to Windows through FTP.
Code using their preferred editor.
Upload finished code, again through FTP, to the unix server.
Use another shell script to convert text to binary format.
Now to my question(s):
Let's say the developers has all the code converted to text in a predefined folder in their machines. Is it possible to configure Jenkins to automatically upload any changes made to their unix account and convert back into binary? And vice versa.
I am currently working on this, but my solution implies installing a script/service which will run continuously in the developers' machines.
I would prefer this other solution, with the goal of in the future starting a CI/CD pipeline from it.
Use any version control system to store code in text format.
Developers will pull, do job and push changes, all in text format.
In Jenkins create job, use Build Triggers to convert to binaries on any changes in version control system. Copy binaries where needed.
I'm a freshman, and I created a server with my roomates in order to practice in maintaining a server.
We installed CentOS7. And I would like to ask how I can install a tool for everyone to use?
More particularly, we want to install Cromwell. But since, they don't have instructions on how to install on Unix, I downloaded Linuxbrew and installed it like this.
The downside is that it's not visible to the other users connected to the servers.
I know this is a noob question, but any response would be appreciated.
A standard unix machine has programs (tools and so on) installed in predefined directories like /bin, /usr/bin, perhaps /usr/local/bin. Which to choose is another matter, probably you want /usr/bin. Also the environ variable PATH plays a role.
Into the chosen directory there should be a file representing the "tool". You can put a copy of the executable file in that directory, and set (or check) its permissions. Execution permission can be granted to all users, or only some, it depends. In other words,
/home/me/.linuxbrew/Cellar/cromwell
is not a good place for a "system" tool or app; you should copy that executable in /usr/bin, set ownership (perhaps to root?) with chown, and set the correct permissions with chmod.
You can make a hard link of your executable into the directory; this saves space, but also means that there is only one copy of the executable. Having two different copies (the "stable" one, and the other one you can fiddle with) can be handy.
After the executable is reachable and executable from the chosen users, maybe it needs some support files. To find them, it can rely on fixed locations, or some environment variable, or some configuration file. But all these things are outside of the scope of the question.
Try this command:
you#machine$ sudo chmod [who][op][permissions] filename
"who" refers to the users that have a particular permission: the user ("u"), the group ("g"), or other users ("o", also known as "world"). "op" determines whether to add ("+"), remove ("-") or explicitly set ("=") the particular permissions. "permissions" are whether the file should be readable ("r"), writable ("w"), or executable ("x"). As an example:
you#machine$ chmod o+x file
will add executable permission for others to file.
I use R under Windows on several machines.
I know you can set the working directory from within an R script, like this
setwd("C:/Documents and Settings/username/My Documents/x/y/z")
... but then this breaks the portability of the script. It's also annoying to have to reverse all the slashes (since Windows gives you backslashes)
Is there a way to start R in a particular working directory so that you don't need to do this at the script level?
You should copy shortcut to R (R.lnk file) to desire folder. Then in "Properties" (right mouse button -> last option) delete anything in field "Start in..." in second tab ("Shortcut"?). If you start R with this shortcut working directory will be that one where the shortcut is.
I don't have english version of Windows so I'm not sure about field names, but they should be easy to find.
Similar questions were in R-windows-faq:
2.5 How do I run it?
2.10 How can I keep workspaces for different projects in different directories?
2.14 What are HOME and working directories?
In 2.14 is mentioned that
The working directory is the directory from which Rgui or Rterm was launched, unless a shortcut was used when it is given by the `Start in' field of the shortcut's properties.
You could use an environmental variable. This can work with Sys.getenv() and Sys.setenv(). For instance:
> Sys.setenv(R_TEST="testit")
> Sys.getenv("R_TEST")
R_TEST
"testit"
If you sent the variable in your script, you should be able to access it from within, and then call setwd() on that output.
Save your workspace to the desired directory and thereafter you just open the workspace from Windows explorer.
I put the following line in front of my scripts and it allows me to work across my computers.
setwd(path.expand("~/path/to/working/directory/") )
where ~ is = to your home directory.
Sys.setenv(HOME = "path") or Sys.setenv(R_USER = "path") can both set the home directory.
In my case, I work on several windows boxes, each have fairly different directory structures, but by setting the home directory properly I can sync code between computers and have them run properly on each one since where I run my R projects have similar directory structures.
If you're using Emacs/ESS, this isn't a problem. I navigate to the directory where my R script is located, open it, then start an R ESS process. An R console pops up with the current directory as R's working directory.
If you haven't converted to Emacs/ESS, I recommend it. (Though to prevent a flame war, I also note there are similar options for Vi users.)
Hope that helps.
Just a detail: instead of reversing the slashes as you say, just add another backslash. Two of these \\ works the same way as one of these /. That makes it at least a little easier.
For Ubuntu:
Insert the following command into your .Rprofile file (usually in your home directory):
setwd(Sys.getenv("PWD"))
Now your default working directory will be whatever directory you launched R from. Keep in mind you can also set up default workspaces in different directories by saving your workspace image as .RData wherever you plan to launch R (startup sources .Rprofile before searching for .Rdata in the cwd).
To set the R work directory like the current directory of the R script that I'm working, I always use a combination of the commands getwd() and setwd(), like this:
path <- getwd()
setwd(path)
or
setwd(getwd())
If you want learn more about it, see this article.
Cheers,
[]'s
To set working directory in R Studio:
Refer detailed slide deck with screen-shots here.
Using setwd(): windows users would need to replace backward slashes '' with forward slashes '/' or double backward slashes '\'
You can do the former using find & replace (Short-cut: Ctrl+F)
Another option: Go to Session --> set working directory --> choose working directory & browse the folder which you want to set as the working directory, click on open
Quickest method (my favorite) use the shortcut 'Ctr+Shift+H' (on windows system), browse the folder which you want to set as the working directory, click on open
To set a permanent working directory (when not in a project) in R Studio:
Refer my quick video on the same: https://youtu.be/hMjzO4bAi70
Go to Tools --> Global Options --> R General [Basic] --> Default Working Directory (when not in a project)
browse the folder which you want to set as the working directory, click on 'Apply' and 'OK'
However, the efficient & better way to organize your work is to create projects & use version control.
Put a shortcut for the R gui into your desired directory. Right-click and look at the shortcut properties. Delete the entry for "Start In" and click OK. When you launch the R gui from this shortcut the default directory will be the folder from which you have launched. Copy/paste this shortcut wherever you desire.