Accessing downloaded databases using sqlite3 on git bash

Hello all

I already have sqlite3 set to open when I type in

sqlite3 newdb.sqlite

The problem comes in trying to access the three downloaded tables from the article on “Learn SQL” titled “What is SQLite?”. The video for installing sqlite3 on windows also recommends downloading three tables which show up as a download as


In short, I have

~/Desktop/SQL $ ls sqlite-tools-win32-x86-3350500/ 'sqlite3 newdb.sqlite.rtf' 'sqlite-tools-win32-x86-3350500 (1).zip'

and in that I have

~/Desktop/SQL/sqlite-tools-win32-x86-3350500 $ ls acs-1-year-2015.sqlite sqldiff.exe* sqlite3.exe* sqlite3_analyzer.exe*

I’ve tried many times accessing the acs file , but all that seems to happen is it jumps to another line without accessing the acs file. This happens if i’m already using a line that has sqlite open or trying to access it using

/.sqlite3 acs-1-year-2015.sqlite

Could someone please help me with this?

I think you’ll have compatibility issues from the get-go trying to run the pre-built windows sqlite binaries in gitbash. Use cmd or powershell for best results or consider using winpty for some slightly improved results like winpty /path/to/sqlite3.exe.

I’m afraid I’m not entirely sure what you meant about jumping lines when accessing files (it might be the issue above as terminal outputs will probably be messy). If that’s not issue could you explain what you did and what you got, How do I format code in my posts? or screenshots might be helpful here if there’s no easy way to explain it.

Oh my. You’re right, That wasn’t what I meant to post at all. Let me see if I can get a screenshot that encompasses my problem. The problem being that I can access sqlite3 from Git Bash either from it’s echo shortcut or from the method shown below.

As you can see, I have a shortcut set to “sqlite3 newdb.sqlite” which will access sqlite3.exe. Inside the folder "Desktop/SQL/sqlite-tools-win32-x86-3350500/ there is a database of three tables titled “asc-1-year-2015.sqlite” that I can’t seem to access.

Ahh it thinks you’re entering a query, so all the text you enter (including your newlines) are just being added to one long query, albeit one with incorrect syntax. You can terminate your query with the semicolon ; followed by return.

I highly suggest running the CLI and using the .help notation (as the text offers) so you can see how to perform certain actions. For example the route to open a specific database file is to use the .open command. Typing in a filename alone is not enough. The input would be more like-
.open ~/path/to/acs-1-year-2015.sqlite

Try the .schema command to see if you opened the database successfully (but read .help since it covers more than I can).

Once again I’d suggest not using gitbash for this. Anyway, the norm would be to set sqlite3 as the shortcut; are you sure that isn’t also the case here? It looks more like you’re opening sqlite3 and using newdb.sqlite as a location for the database file (a new file basically).

sqlite3 ~/Desktop/SQL/sqlite-tools-win32-x86-3350500/asc-1-year-2015.sqlite would be the typical way to open that database, for example would load the database you’re after, assuming it was set up correctly.

You’re a lifesaver. At the very least a savior from my mental anguish.

Well, I think the database is accessed. I loaded the google example of what the tables should look like and tried seeing what I would be working with, but to no avail.

I’ll try looking into the .help and .schema resources when I have a moment. Thankyou for your time.

1 Like

Haha, a shared suffering perhaps. I’m fairly familiar with command line programs and I still found it a little troublesome, at least until I got used to it (without reading the manual it is hard to know what is going on). I appreciate them keeping sqlite small but it could really really do with some slight improvements to the CLI, even a couple of lines of feedback about success or failure when starting up and opening the file would help no end.