SQLite in Git Bash

Hey guys, I have one question. I have been doing this SQL course and I am on Go off platform phase.

I tried to do everything like mentioned on this site. (https://www.codecademy.com/paths/data-science/tracks/analyze-data-sql-go-off-platform/modules/analyze-data-sql-learn-off-platform/articles/what-is-sqlite)

There is especially one part that does not seem to work in my Git Bash :
echo "alias sqlite3=\"winpty ${PWD}/sqlite3.exe\"" >> ~/.bashrc

and

source ~/.bashrc

After I entered this into my command line it did not open SQL. But after this - winpty ./sqlite3.exe it did. So I tried doing this insted :

gregor@DESKTOP-97545EP MINGW64 ~/desktop/learning/sqlite-tools-win32-x86-3320300
$ alias sqlite3=“winpty ./sqlite3.exe/”

^C

gregor@DESKTOP-97545EP MINGW64 ~/desktop/learning/sqlite-tools-win32-x86-3320300
$ source ~/.bashrc

gregor@DESKTOP-97545EP MINGW64 ~/desktop/learning/sqlite-tools-win32-x86-3320300
sqlite3 SQLite version 3.32.3 2020-06-18 14:00:33 Enter ".help" for usage hints. Connected to a transient in-memory database. Use ".open FILENAME" to reopen on a persistent database. sqlite> gregor@DESKTOP-97545EP MINGW64 ~/desktop/learning/sqlite-tools-win32-x86-3320300 sqlite3 acs-1-year-2015.sqlite
SQLite version 3.32.3 2020-06-18 14:00:33
Enter “.help” for usage hints.
sqlite> SELECT * FROM states;
2015|Alabama|04000US01|4858979|3204076|1296681|192870|58918|19069|2566|5590|38.7
|1846390|134100|44765|44765|876016|169972|01
2015|Alaska|04000US02|738432|452472|24739|51825|45753|98300|6341|2201|33.3|25018
5|259600|73355|73355|74532|58544|02…

And I got same correst result as an guy on video. I guess my way is not the best one and there is some catch in it. What is difference between my approach and instuctors. Do you have an idea why the first aproach was not working for me?

Thanks

Hi @bit5955278864,

Welcome to the forums!

So the difference between the instructions and what you did is that the alias given by the instructions can be used from anywhere on the system. The alias you created, however, is specific to the file containing sqlite3.exe If you were to navigate to a different folder in Git Bash and try that alias, it would not work. (./sqlite3.exe tells bash to open “the sqlite3.exe file in this folder”). Also, your command:

doesn’t allow Git Bash to recognize your alias after you close Git Bash, since you are not writing it to the .bashrc file.

So, that being said, what exactly went wrong when you followed the instructions? It sounds like you expected those commands to open SQLite, but they are only meant to set the alias. After running these commands…

  • echo "alias sqlite3=\"winpty ${PWD}/sqlite3.exe\"" >> ~/.bashrc
  • source ~/.bashrc

… you need to close Git Bash and open it up again. Then after that, you should be able to use the command sqlite3 in Git Bash to open SQLite from any folder.

Let us know if you if you have any more questions!

1 Like

Thanks. What a simple thing and I did not get it.