How to connect a database in Atom Editor? - sql

I want to connect my database in atom and execute directly from the editor. How can I do that?

Install a package "data-atom" Reference. You can do it in two ways :
1.Through command line (windows) :
apm install data-atom
make sure you have ssl false, if not then type
apm config set strict-ssl false
before "apm install"
2.Open atom and go to settings and click on "+Install" and look for "data-atom" package.
Once you downloaded, restart atom and do "alt+shift+r" to open database window. Fill in the configuration and you are good to go.
Hope this helps

Install data-atom as recommended already by Sdembla. But beware, the recommended commands in the documentation for these packages do not work, until you first use "Edit connections", to create a connections file for it to work with.
Interestingly this also applied to the "data-ace" Atom package.
The exact steps (assuming you've installed the data-atom package, and restarted Atom) are...
click Packages > Data Atom > Edit connections
replace the generic file contents ("[ ]") with a connection config, like that shown in guzman's question here:
[
{
name: "WindowsAuthentication"
protocol: "sqlserver"
user: "username"
password: "password"
server: "apphost/Username"
database: "master"
options: ""
}
{
name: "SQLServerAuthentication"
protocol: "sqlserver"
user: "userlogin"
password: "password"
server: "apphost/sqlexpress"
database: "master"
options: ""
}
]
the other commands (eg ctrl-shift-R) should now work ๐Ÿ˜Ž
it's important you Save this connections file, otherwise the commands will stop working again.

Related

How to change default directory in Windows Subsystem for Linux

I am setting up my development environment, so I just installed Windows Subsystem for Linux and it always seems to open a fresh terminal in my Windows home directory - /mnt/c/Users/dl and I'm trying to make it default to the linux home directory - /home/dl.
I checked to see what the home directory is in the Linux subsystem in /etc/passwd and it is correctly set:
dl:x:1000:1000:,,,:/home/dl:/bin/bash
Then I came across this solution, but it doesn't seem to have any affect:
// Set starting directory
"startingDirectory": "\\\\wsl$\\Ubuntu\\home\\dl\\"
I know I can just run cd ~ in my dot files (which is what I'm currently using), but I'm looking for a way where /home/dl is just the default and cd ~ isn't needed. Is this possible?
You should only change the startingDirectory for WSL (Ubuntu in this case) terminal sessions.
Open settings.json via CTRL+SHIFT+,
Make sure you are modifying startingDirectory under profiles/list/name: "Ubuntu"
Example below (the slashes need to be escaped):
....
{
"guid": "{2c4de342-xxx-xxx-xxx-2309a097f518}",
"hidden": false,
"name": "Ubuntu",
"source": "Windows.Terminal.Wsl",
"startingDirectory": "\\\\wsl$\\Ubuntu\\home\\windows_username_in_lower_case"
},
....
Documentation about startingDirectory including default values and expected values.
Inside settings.json you will also find an explanation of the json schema which is here
If you need to know how or where to edit Windows Terminal settings/preferences: https://learn.microsoft.com/en-us/windows/terminal/get-started
In Windows 10 21H2 or later and Windows 11, it's now much simpler. According to the Microsoft Doc:
On newer versions of Windows, startingDirectory can accept Linux-style paths.
That means you can simply use:
"startingDirectory": "/home/yourusername"
No need for any prefixes for Windows directory structure, nor escaped backslashes. Just plain old Linux forward-slash notation.
This works in both WSL1 and WSL2.
Note: I tried to use "~" and it failed. There may be some way to use {$USERPROFILE}, but haven't tried it.
Changing the home directory with WSL is done the same way as in Linux:
Enter bash
Type the command sudo vim /etc/passwd
Find your account's line, which might look like:
shadyar:x:1000:1000:"",,,:/home/shadyar:/bin/bash
Change the home directory, which above is /home/shadyar, to the new directory, using WSL
note: If you want to set Windows directory as home directory, you need to prepend it with /mnt/, like /mnt/c for C:/, /mnt/d for D:/, etc
Save the file and exit vim by typing :wq and press Enter
Exit bash and re-launch it
To test, use the commands:
cd ~
pwd
The other answers here (especially the latest one from #TomBoland) are great for starting in an arbitrary directory, but the example in your question was to start in your home directory. The easiest way to do that is simply to create or change the "commandline" property to wsl ~. This is an undocumented flag to wsl.exe, and it must be the first argument (e.g. wsl ~ -u root).
Current and Recent Windows Terminal Releases
Since Windows Terminal now has a GUI for Settings, you can just edit your profile to point to wsl ~ in the ->General->Command Line setting.
Older Windows Terminal Releases, or if you want to edit manually
If you are editing your settings.json directly (currently found in %userprofile%\AppData\Local\Packages\MicrosoftWindowsTerminal...\LocalState\settings.json, but this may change) ...
Remove the "source" attribute and replace it with "commandline":
"guid": "{2d5ef231-38b7-51cf-b940-2309a097f644}",
"hidden": false,
"name": "Ubuntu",
//"source": "Windows.Terminal.Wsl",
"commandline": "wsl ~",
"startingDirectory": "//wsl$/Ubuntu/",
"tabTitle": "Ubuntu"
Also, for the fun of it, here's an alternative (hacky) way to open WSL to ~/$HOME (without hardcoding as with the other answers). This is absolutely not needed since it's much easier to use wsl ~, but:
wsl -e sh -c 'cd $HOME; exec $SHELL'
This starts up sh, changes the directory to $HOME, and then exec's your $SHELL to replace the sh.
Should you use Windows Terminal with WSL, then the simplest solution is to configure the starting directory via the Settings menu:
and then:
startingDirectory Should be a windows path, not a nix path. Try D:\Folder\SubFolder instead
refer this link,worked for me
github
I tried many things here and none worked but I finally found a workaround.
After opening your ubuntu, you can set the default path by editing your .bashrc file.
I personally wanted to change it from the default /home/${my_username} to my current user directory (like command prompt C:/users/${my_username}), so I just ran this in my Ubuntu terminal
echo 'cd "../../mnt/c/users/${my_username}"' >> $HOME/.bashrc
Step 1: Open windows command prompt and type "bash"
or open Linux app directly .
Step 2: Type a route which is something like this : /mnt/c/Users/HP/..(You can enter your desired directory here).
For example : /mnt/c/Users/HP/Documents , and by this you will get inside Documents.
For WSL2 Ubuntu the syntax should now match the following example in the json:
"guid": "{2d5ef231-38b7-51cf-b940-2309a097f644}",
"hidden": false,
"name": "Ubuntu",
"source": "Windows.Terminal.Wsl",
"startingDirectory": "//wsl$/Ubuntu/",
"tabTitle": "Ubuntu"
To start in /: "startingDirectory": "//wsl$/Ubuntu/",
To start in /root: "startingDirectory": "//wsl$/Ubuntu/root/",
To start in /home: "startingDirectory": "//wsl$/Ubuntu/home/",
No need to do any of that, just open up the profile for Ubuntu under settings, then update the Command line to add the following option
C:\Windows\system32\wsl.exe -d Ubuntu --cd ~

How do I get Windows 10 Terminal to launch WSL?

I'm using the new Windows Terminal, and trying to get it to launch my WSL terminal. This is the setting that I'm trying to use:
{
"acrylicOpacity" : 0.75,
"closeOnExit" : true,
"colorScheme" : "Campbell",
"commandline" : "%LOCALAPPDATA%/wsltty/bin/mintty.exe --WSL= --configdir='%APPDATA%/wsltty' -~ ",
"cursorColor" : "#FFFFFF",
"cursorShape" : "bar",
"fontFace" : "Consolas",
"fontSize" : 10,
"guid" : "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
"historySize" : 9001,
"icon" : "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png",
"name" : "wsl",
"padding" : "0, 0, 0, 0",
"snapOnInput" : true,
"startingDirectory" : "%USERPROFILE%",
"useAcrylic" : true
}
But all it's doing is opening some sort of CMD.
What's the correct command to run the WSL terminal
Edit:
I did notice that the GUID was the same thing as the regular CMD, so I changed that. Then it did launch an external shell.
You need to do following things first.
1. Install Linux (e.g. Ubuntu)
Search "Ubuntu" in the Microsoft store, then buy and install. This is actually WSL (Windows Subsystem for Linux).
Of course, you want to experience other versions of Linux, as well as Debian:
2. Enable WSL permissions
After installing the WSL version of Linux, you also need to enable WSL permissions:
Open another PowerShell window with "Run as Administrator".
Then enter the following command:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
After the command is completed, you can execute the Linux command in the built-out Terminal.
First enter ubuntu in cmd, take a little time to start Ubuntu, set the username and password.
Then you can play with Ubuntu happily. Below I entered a few common commands such as ps, touch, ls etc., as shown below.
3. Change settings
Click "Settings" in right top corner of above image, the file profile.json file will be opened. Then inside the word "profiles" in profile.json file, add below snippet.
{
"guid": "{78e390db-1bff-4533-9d7c-20f53d8bafa1}",
"name": "WSL",
"colorscheme": "Campbell",
"historySize": 9001,
"snapOnInput": true,
"cursorColor": "#FFFFFF",
"cursorShape": "bar",
"commandline": "wsl ~",
"fontFace": "Consolas",
"fontSize": 12,
"acrylicOpacity": 0.75,
"useAcrylic": true,
"closeOnExit": false,
"padding": "0, 0, 0, 0"
}
Near the word "schemes" in profile.json file, you need to update below:
"schemes": [
{
"name": "Campbell",
"foreground": "#A7B191",
"background": "#0C0C0C",
"colors": [
"#0C0C0C",
"#C50F1F",
"#13A10E",
"#C19C00",
"#0037DA",
"#881798",
"#3A96DD",
"#CCCCCC",
"#767676",
"#E74856",
"#16C60C",
"#F9F1A5",
"#3B78FF",
"#B4009E",
"#61D6D6",
"#F2F2F2"
]
}
The complete setting file (profile.json) which can be obtained here.
Actually, the WSL here is Ubuntu.
4. Add icons to different types of tabs
You can add icons for Tab to this location:
%LOCALAPPDATA%\packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\RoamingState
I put some 32x32 PNG in this folder, and then in profile.json I can reference the image resource with the path starting with ms-appdata:// .
The icon is available here:
Icons
Then replace the contents of the new profile-withIcons.json file below with the previous settings.
profile-withIcons.json
After finishing the contents of the folder is like this:
The final result is:
To launch any distribution, you can also use this for commandline:
wsl.exe -d <name_of_the_distribution>
Like :
wsl.exe -d Ubuntu-18.04
You can list all distributions with :
wsl.exe -l
.
PS : Tux icon for Linux :
ms-appx:///ProfileIcons/{9acb9455-ca41-5af7-950f-6bca1bc9722f}.png
Turns out that all I needed to do was change the commandline to ubuntu1804.exe. Like this:
{
"acrylicOpacity" : 0.75,
"closeOnExit" : true,
"colorScheme" : "Campbell",
"commandline": "ubuntu1804.exe",
"cursorColor" : "#FFFFFF",
"cursorShape" : "bar",
"fontFace" : "Consolas",
"fontSize" : 10,
"guid" : "{0caa0dad-35be-5f56-a8ff-abceeeaa6101}",
"historySize" : 9001,
"icon" : "ms-appx:///ProfileIcons/{0caa0dad-35be-5f56-a8ff-afceeeaa6101}.png",
"name" : "wsl",
"padding" : "0, 0, 0, 0",
"snapOnInput" : true,
"startingDirectory" : "%USERPROFILE%",
"useAcrylic" : false
}
While my answer is off-question (since answered by the O.P.) I found this question while searching for adding a Windows Terminal (WT) profile for my recent Ubuntu installation, since I had recently re-imaged my laptop.
Updated 19/10/03: Installation order does not matter. My profile for โ€œubuntuโ€ appears after installing ubuntu, and then launching the ubuntu instance in PowerShell and establish my user account and password. THEN Windows Terminal adds the appropriate shell profile for WSL.
I have developed a tool for tweaking the terminal configurations here :
Windows Terminal Tweaker ๐Ÿš€โšก
It lets you add different profiles , gives color pickers to choose color schemes and provides options to tweak every single thing while applying the settings live.
Open settings
Change the "Default Profile" in the drop down.
Click "Save" on the bottom right.
Create a new profile in the windows terminal settings and select the following command line
C:\Windows\system32\wsl.exe -d Ubuntu-20.04
where -d selects the distribution to be run.
Windows Terminal allows you to open the settings and change things there. If you already have ubuntu installed, it should be an option to set the ubuntu profile as your default config.
Copy paste the guid for ubuntu into the defaultProfile and it will automatically launch WSL ubuntu instead of powershell by default.
The premise of the question was fouled by the mistake with the GUID, as the OP says the sample code was actually correct. So, the question could be re-interpreted as--
What is the minimum required change to the default settings.json to point to an application of your choosing? (which is what got me here)
guid - has to be unique. I've had success with changing just the last number for each customization.
commandline - From within Bravo Yeung's answer is a link to a sample settings.json file: "commandline": "wsl ~"
This little bitty value is made possible by setting a default distro: "The default WSL distribution is the one that runs when you run wsl on a command line:"
wsl --setdefault <DistributionName>
However, seems commandline:wsl doesn't work with startingDirectory.
I've successfully omitted commandline in favor of source + startingDirectory:
// Make changes here to the cmd.exe profile.
"guid": "{long-guid-here}",
"hidden": false,
"name": "Debian",
"tabTitle" : "WSL (Debian)",
"source": "Windows.Terminal.Wsl",
"startingDirectory" : "C:\\Users\\myuser"
Here is a good link which got me started the first time I installed Windows Terminal and customized the settings, Easily add Anaconda Prompt to Windows Terminal to make life better
Recent versions of Windows Terminal include support for Dynamic Profiles, in which new WSL distros will automatically be added to the list of available profiles.
However, if Windows Terminal is running when you install the new distro, it will not currently get added while running. You must exit and re-start Windows Terminal, and the new profile will automatically appear.
Once it is added, you can edit/move it using the Settings dialog or by editing settings.json as usual. Each WSL distro is identified using a GUID which will have been auto-populated.
As described in the linked article, Dynamic Profiles can be turned off by disabling their source(s) such as the following in settings.json:
"disabledProfileSources": ["Windows.Terminal.Wsl", "Windows.Terminal.Azure", "Windows.Terminal.PowershellCore"]

Can not connect to Db- Dump using codeception

I am struggling to use the db functionality of codeception framework. The error i am getting is
Db: could not find mysql driver while creating PDO connection
actor: AcceptanceTester
modules:
enabled: [Db, PhpBrowser]
config:
Db:
dsn: "mysql:host=localhost;dbname=my_db"
user: 'root'
password:
populate: true
cleanup: true
dump: 'tests/_data/Dump20180423.sql'
PhpBrowser:
url :
My acceptance.suite.yaml file is set like this.
Also my dump file has the CREATE TABLE command inside.
The path for Mysql is already set in the environmental variables path.
The pdo extensions are set inside my php.ini file
I guess it's a problem with the dsn as it fails before validating my user credentials. Also my mysql works fine. I have projects that i use PDO connection and they work without any issue.
I tried every solution i could find but still getting the same error. Thank you in advance for any help!!!
So after many hours/days i finally found out the solution to this. The problem was coming from my cygwin (linux console). While my php.ini file was fine and php info was sawing i had pdo_mysql installed and everything seemed like that, cygwin had a different opinion. I had to install pdo_mysql inside cygwin so the command :
php vendor/bin/codecept run could connect to the database and work!!!
Typing php -m in my cygwin console showed me that i was missing this module (pdo_mysql).
After that the problem is solved and my tests work fine.

How to manage a project folder via ssh?

Developing full-stack web apps, I would like to have all my code and build logic on a linux machine (i.e. git, docker containers and other terminal commands), but all my development workflow on my windows machine (so my IDE, web browser and REST client) accessing it via SSH.
I've managed to do all of that except for the IDE, I could only edit individual files via SSH instead of managing a folder as a project. So right now I use VSCode on the linux machine (Ubuntu), and it's the last thing preventing me for dropping the graphical interface and install Ubuntu Server on it.
And no, I don't want to use Vim or Emacs. I want to use VSCode, or another modern IDE, but preferably VSCode.
Try using the Remote VSCode plugin as explained here: Using Remote VSCode
This discussion is exactly about your problem: VSCode 13643 issue Github
EDIT: I have recently found a new VSCode plugin on Github: vs-deploy. It was designed to deploy files and folders remotely very quickly. It seems to be working and I haven't found any bugs so far. It works with FTP, SFTP (SSH) and many other protocols.
The SSH.NET nuget Package can be used quite nicly to copy files and folders.
Here is an example:
var host = "YourServerIpAddress";
var port = 22;
var user = "root"; // TODO: fix
var yourPathToAPrivateKeyFile = #"C:\Users\Bob\mykey"; // Use certificate for login
var authMethod = new PrivateKeyAuthenticationMethod(user, new PrivateKeyFile(yourPathToAPrivateKeyFile));
var connectionInfo = new ConnectionInfo(host, port, user, authMethod);
using (var client = new SftpClient(connectionInfo))
{
client.Connect();
if (client.IsConnected)
{
//TODO: Copy folders recursivly etc.
DirectoryInfo source = new DirectoryInfo(#"C:\your\probject\publish\path");
foreach (var file in source.GetFiles())
{
client.UploadFile(File.OpenRead(file.FullName), $"/home/yourUploadPath/{file.Name}", true);
}
}
}
When you create a upload console application using the code above your should be able to automatically trigger an upload by using postbuild events by adding a section to your Project.
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="path to execute your script or application" />
</Target>
If you prefer to do the same but more manual you can perform a
dotnet build --configuration Release
followed by a
dotnet publish ~/projects/app1/app1.csproj
and then use the code above to perform an upload.
Search for the extension SSHExtension developed by Vitaly Kondratiev
Install the extension.
And edit the serverlist json with the server details.
ex:
"sshextension.serverList": [
{
"name": "Kuberntes 212",
"host": "10.64.234.54",
"port": 22,
"username": "root",
"password": "byebye"
}
]
save the file
Then log in using ctrl+shift+p and choose sshextension open ssh extension category. It shall create a session for you.
More Easily if u need the entire directory structure into ur local workspace.
Use extension ftp-simple in vscode. It works as a wonder, trust me.
Install ftp-simple in vscode
ctrl+shift+p
select ftp-simple:config.
Configure your settings
[
{
"name": "Kubernetes 212",
"host": "10.75.64.2",
"port": 22,
"type": "sftp",
"username": "root",
"password": "byebye",
"path": "/home/vinod/",
"autosave": true,
"confirm": true
}]
save the file.
Now ctrl+shift+p
and select ftp-simple:remote directory to workspace.
Viola Your work is done, Life is simple

how can I install "elm-light" on windows?

elm-light looks like a great plugin for elm in the LightTable editor, but I can't make it work properly on Windows. When I try to establish a connection, I get this error : Path must be a string. Received null.
Please help...
"Path must be a string" should already be fixed in elm-light-0.42
AST
Auto-completions only starts working once you have connected to an Elm project. You can force "suto.connection", through various commands (Lint, toggle docs etc). So if you hit "ctrl-d" on a symbol when you aren't connected, it will connect for you. Another option is to add the Lint command to the save operation in Light Table. Again see Useful configurations
-- https://rundis.gitbooks.io/elm-light-guide/content/chapter1.html
After opening elm file in Light Table, you can see at the status: AST not connected. That means elm-light doesn't run yet.
You have to connect manually either by running ctrl+space > ELM: Load/reload project AST or better by mapping this action to save.
To do this, run ctrl-space > Settings: User keymap. Add line [:editor.elm "ctrl-s" :save :elm-format :elm.lint] before last ] so it looks like this:
[
;; ...
[:editor.elm "ctrl-s" :save :elm-format :elm.lint]
]
Above mapping to ctrl-s will also format and lint your file.
One more thing. If you type for example import Dict as Dict exposing (, AST will report error. For that we need to automatic brackets close. To do that, run ctrl-space > Settings: User behaviors and add line [:editor :lt.objs.editor/autoclose-brackets], so that the file looks like that:
[
;; ...
[:editor :lt.objs.editor/autoclose-brackets]
]
Avoid spaces in the path to the elm-platform
type echo %path% in a Windows command prompt to check the Elm path
uninstall and reinstall elm in another folder if necessary
Avoid spaces in the path to LightTable
move the LightTable folder if necessary
uninstall and reinstall the elm plugin in the new location
Install elm-oracle
execute npm install elm-oracle in a Windows command prompt to get auto-complete to work.
Install elm-format
Configure keymaps
use ctrl- (Windows) instead of cmd (iOS) in the keychords