Problem of setting sqlite3 path to environment and opening database

Hello,

I just installed sqlite3 and added it to environment.
I am now able to open to run sqlite3 from CDM. I can open database. However when I add database command .schema does not work and returns nothing. Can somebody please help to explain what is happening?

However if I open CMD and provide path of sqlite3 and open sqlite3.exe and provide name of database then it magically works. What is the reason for that?.

For some reason I need to provide a a path to sqlite3 then open sqlite3 and then it adds database correctly. Database and sqlite3 are in the same place.
Should it not work when full path of sqlite3 is added to environment?.

If you look in C:\Users\Chata there’s a file acs-1-year-2015.sqlite there because that’s what you told sqlite to open. (it even says so in your screenshot)
You told it to open two different files.
If you want to open a file somewhere other than in your current directory then you would need to provide an absolute path to that file, not just the base name.
Your PATH variable is unrelated to this.

Thanks for answer.

I was under impression it would work as a relative path as SQLite and database are in the same place.
I thought if I provide SQLite path in environment , then I can open databases in relative directory by just providing the name of data base as both are in the same place.

Also how can I open it once in SQLite3?. By providing full path as in example below doesn’t work.
Full path or database name does not work with .open.

Error with .open Absolute path:

Error with file name of database in same directory as SQLite:

The problem isn’t that sqlite can’t read a path, the problem is your path is invalid. It echo’d it back to you, note what happened to the backslashes. Presumably you would need double backslashes, backslash is a common character used for escape sequences.

If you do not supply full path then yes, the location you are then specifying is relative to YOUR location. Not to the executable’s location, that’s irrelevant.

1 Like

What is the point of providing full path of SQLite to environment if I cannot open database file by providing full path of it afterwards with .open command or just a name of the file?.

The point is to type:

sqlite3

instead of the full path to the executable

1 Like

Yes, but then how can I open the database file?. It comes up with error when i provide full path of file with .open command.

Provide a valid path to your db file or change your current directory to the same directory as the database file is in and use a relative path

use forward slashes or double backward slashes, presumably

1 Like

This is the file path

1 Like

Double backward slashes didnt work, but forward slashes worked!
I was doing it wrong all the time as CMD path can be done with backward slashes.
Would you know what is the command to change current directory?. I would really want to make it work with relative path and thought that environment path would do this.

probably cd

1 Like

It is .cd i googled it. Thank you for help. Much appreciated

If you’re going to use a commandline shell you might wanna consider using something other than windows, if you take a look in windows store there’s an app there named ubuntu… ubuntu is a linux distribution, an operating system, a list of programs ready to be downloaded and installed.
That’s pretty darn close to a linux system (with the difference that … well it probably dosen’t have linux in it, instead running on the windows kernel … I think), you only get a terminal but that’s also the only thing you’d ever want.

To install sqlite in that you would do something like:

$ apt update && apt upgrade && apt install sqlite3

(which is three commands to be run in sequence)
the first one updates the package index, the second one syncs local packages with that package index, the third installs the sqlite3 package

It’d take a while because it’s equivalent to a full system update and a newly installed system might have a couple things to catch up on… but after that you would have sqlite3 ready to be run:

$ sqlite3
SQLite version 3.31.1 2020-01-27 19:55:54
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> 

(it’s basically a virtual machine, separate from your system, hosted by your system. file access goes through the network, there’s some special network directory for that)


The reason you might want to do that is because while you’re using windows you’ll probably end up using a whole lot of workarounds more complicated than the thing you’re trying to do.
And, well, installing things is one command (apt install <package>), there’s no silliness like going to a website and downloading it with your browser and running a graphical installer and so on

But you might also not really have a need for a commandline shell in which case… whatever. But if you do, it should probably be this, not anything inside windows.

1 Like

Thank you ionatan.
I am definitely going to look at it.

I was also looking at MySQL on Visual studio code and also XAMPP.
Would you recommend it?.

Isn’t the M in that for mariadb? (which is a MySQL fork)

vscode is an editor… I guess you would want an editor… right? but yeah, that is probably the only editor that can be easily recommended to other people (I don’t use it, but if I wasn’t using the one I do that’s probably what I’d use)

there is almost certainly a package containing mariadb and/or mysql in ubuntu, you’d do something like

$ apt search mariadb
$ apt install some-match-you-found-from-previous-command

and to start that database it would probably be something like

$ systemctl start mariadb.service

recommend it? err doubt I can say anything meaningful about that. sure I guess?

1 Like

What are you using yourself? if I may ask.

I am very tempted to start using ubuntu.

using for what?