I downloaded the binaries for windos for sqlite and extracted them. There were three files
a shell
dll
analyzer
when I try to run to create a database and a table from the sqlite shell i get....
SQLite version 3.7.8 2011-09-19 14:49:19
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> sqlite3 test.db
...> create table tbl1(one varchar(10), two smallint);
Error: near "sqlite3": syntax error
sqlite>
when I try to run to create a database and a table from the command line(Vista) shell I get....
Microsoft Windows [Version 6.0.6000]
Copyright (c) 2006 Microsoft Corporation. All rights reserved.
C:\Users\codenamejupiterx>sqlite3 test.db
'sqlite3' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\codenamejupiterx>
does anyone have any ideas?????
There is no "installation".
The error is that "sqlite3.exe" was not found in the search path as defined by the (Windows) PATH environment variable. Either add it to %PATH% (see How do I set or change the PATH system variable?) or use a complete file qualification that does not rely on %PATH%. A fully qualified invocation may look like:
C:\path\to\sqlite\sqlite3.exe test.db
Running sqlite3 by "double clicking" the executable in Windows Explorer is the same as above [as it uses an absolute path to run the sqlite3 executable] -- albeit without the ability to specify the database name or other options. (These can be specified in a "shortcut" to sqlite3, if desired.)
Happy coding.
You run the command sqlite3 test.db to start the sqlite shell. (your first example) From in there, you do not need that part of the command again, just issue the "create table " command.
I think you need this:
SQLite-1.0.66.0-setup.exe And sqliteadmin to open sqlite database
Regards
Related
I used the following on the cmd to try and open the sqlite command line interface, but somehow it is not recognised.
I can see the sqlite db has been created, so cannot see what I am doing wrong:
(env) E:\Python installation\myproject\myflaskproject>sqlite
'sqlite' is not recognized as an internal or external command,
operable program or batch file.
(env) E:\Python installation\myproject\myflaskproject>
I've also tried typing at the prompt: >>sqlite3
Still, the same error.
download slqlit3
to download slqlit3 go to this url: https://www.sqlite.org/download.html
since your are working on windows platform, under Precompiled Binaries for Windows section download sqlite-tools-win64-x64-3320300.zip or sqlite-tools-win32-x86-3320300.zip if your are like me working on the very OLD windows 7 32bit architecture
you have to know sqlite3 is a standalone and executable file meaning sqlite3 don't require to be installed like other programs:
A bundle of command-line tools for managing SQLite database files, including the command-line shell program, the sqldiff.exe program, and the sqlite3_analyzer.exe program.
unzip the downloaded file the under C:\ for e.g. and rename the folder to C:\sqlite3 to make things simple.
now, if you open : C:\sqlite3, you'll find 3 executable files:
C:\sqlite3
sqldiff.exe
**sqlite3.exe**
sqlite3_analyzer.exe
add an Environment Variable
open System Properties (see this post)
go to Advanced tab under System Properties and click Environment Variables
Under System Variables create those variables:
PYTHON_HOME = C:\Python37 (it depends where you already installed python and which version if you have multiple installations)
SQLITE_HOME = C:\sqlite3
go to User variables and add/append variables to PATH like so:
PATH = [..];%PYTHON_HOME%;%PYTHON_HOME%\Scripts;
open new console and check your current active python:
python --version
and then you can use sqlite3 command not sqlite (check the C:\sqlite3 installation folder):
(env) E:\Python installation\myproject\myflaskproject>sqlite
'sqlite' is not recognized as an internal or external command,
operable program or batch file.
(env) E:\Python installation\myproject\myflaskproject>sqlite3 -version
3.15.2 2016-11-28 19:13:37 bbd85d235f7037c6a033a9690534391ffeacecc8
now you can open the sqlite database file (e.g: data-dev.sqlite3 under /myflaskproject ) like
(env) E:\Python installation\myproject\myflaskproject>sqlite3 data-dev.sqlite3
SQLite version 3.15.2 2016-11-28 19:13:37
Enter ".help" for usage hints.
sqlite>
some quick useful sqlite commands
sqlite> .databases
seq name file
--- --------------- ----------------------------------------------------------
0 main E:\Python installation\myproject\myflaskproject\data-dev.sqlite3
sqlite> .tables
user
sqlite> .exit (to exit)
for more about sqlite have look at this site sqlitetutorial.net
I am new to SQLite3.
I am trying to create a DB in the shell. When I run the shell, it already shows:
SQLite version 3..
Enter ".help" for instructions ..
Enter SQL...
Enter SQL statements terminated with a ";"
I read somewhere that I should be able to type "$" and codes like "$ sqlite3 mynotes.db"
Now, I need to be able to name my DB (like "mynotes.db") and be able to decide in which folder I want it to be saved.
Can someone help me? Cheers!
The $ somewhere was supposed to be a prompt of some shell (command processor), where you start sqlite3 and specify database name (which is created if does not exists).
If you're running sqlite3 without a shell (by clicking on sqlite3.exe?), it's time to try another way. CMD.EXE on Windows is as good for this job as a typical Unix shell.
As of the folder where the database will be: either cd to this folder before you run sqlite3 mynotes.db, or specify full pathname to the database: sqlite3 "C:\Users\Me\Documents and Settings\mynotes.db" (double quotes are needed when argument contains spaces).
When sqlite3 is started with no parameters, the database will be in memory. Sqlite3 supports "attaching" other databases (see ATTACH DATABASE description). This way, you can create and open on-disks databases even if starting sqlite3 with parameters is impossible for some reason (or too hard).
I need to convert from sqlite2 db to sqlite3, is there any tutorial that shows how to do it? And if I migrate correctly what to expect as I start the project?
The SQLite website says:
sqlite OLD.DB .dump | sqlite3 NEW.DB
where sqlite is version 2 and sqlite3 is version 3.
Converting an SQLite2 database to an SQLite3 database on Windows
-- Step-by-step instructions --
1- Download SQLite2 and SQLite3 command-line tools
Download links:
sqlite.exe
http://web.archive.org/web/20031203050807/http://sqlite.org/download.html
(Precompiled Binaries For Windows)
sqlite3.exe
http://www.sqlite.org/download.html
(Precompiled Binaries for Windows)
2- Copy sqlite.exe, sqlite3.exe and the db to convert to the same folder (i.e.: D:\TEMP)
3- Open a Windows command prompt ( [WINDOWS KEY] + [R], then type "cmd" or via the Start Menu)
4- Browse to the folder where you've just copied the files (i.e.: type "D:", then "cd temp")
5- Type "sqlite OLD.DB .dump | sqlite3 NEW.DB" (without the quotes), where OLD.DB is the db file you want to convert and NEW.DB is the name of the converted file that will be created.
Hope this helps.
EDITED: ANSWER TO THE QUESTION
To the conversion
Go to http://www.sqlite.org/download.html
Download sqlite-dll file (which stays in Precompiled Binaries For Windows)
Unpack it and copy to C:\Windows\System32 folder
What are the differences? (quoted from PHP - SQLite vs SQLite3)
SQLite2 internally stores every value as a string, regardless of its type.
Upgrading to SQLite3 will certainly shrink the database size since numbers and BLOBS get stored in their native formats, which could make things run faster.
starting from 3.6.23 version it supports foreign keys.
I have my sqlite3.exe file in C:\ and i want to create an sqlite database in C:\db\sqlite.I have tried sqlite3 ex1 as suggested on the docs http://www.sqlite.org/sqlite.html but i get the error Error Near "sqlite3".
What is the correct way of creating a new database from the shell?.
Here is one way to use SQLite3 from the command prompt in Windows.
First you need to know the path to the folder where you installed the SQLite ODBC Driver. If you used the default settings this would be C:\Program Files\SQLite ODBC Driver on Windows XP
Go to Start -> Run -> type cmd -> click OK
This opens the command prompt.
In the Shell, type in the following command. You can use Alt + Space if you prefer to use cut and paste. Remember to modify the path for your setup if you installed SQLite in another folder.
cd C:\Program Files\SQLite ODBC Driver
This brings you to the SQLite install folder. Now you are ready to call SQLite. Type the following command at the SQLite prompt.
sqlite3
This opens the File menu where you can choose a database to connect to, or create a new database file.
Navigate to C:\db\sqlite and create myDatabase.db, and click Open to close the file menu.
Now you are ready to work on your new database, run your queries, e.g. create a table.
As new file is created in current directory, for creating file at different location you should follow this format:
eg. for storing file FILENAME.db at c:/users/xyz/abc
you should type
sqlite>.open c:/users/xyz/abc/FILENAME.db
and then press enter a new file will be created at the mentioned path.
and now when you will type .databases you will see your file listed in the list of databases.
You can use following command to create the sqlite database
.open databasename.db
or
.open c:/somefolder/databasename.db
I tried using the following commands to create a database file at prompt, but none of them would work.
$ sqlite3 test.db
sqlite3 test.db
test.db
does it require a semi-colon at the end or is it that hard to create a database file using sqlite3 prompt?
Edit:
When I start the sqlite3 prompt, I get
SQLite version 3.6.22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>
when type "sqlite3 test.db" I get,
SQLite version 3.6.22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> sqlite3 test.db
...>
where should be the test.db file on the disk?
If you want a blank .db file just use:
touch stuff.db
I think the problem may actually be that the file does not seem to get created on disk until after you perform such action such as CREATE TABLE.
my actions:
C:\path\to\sqlite3.exe test.db
SQLite version 3.7.13 2012-06-11 02:05:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> .quit
no file was created.
Then:
C:\path\to\sqlite3.exe test.db
SQLite version 3.7.13 2012-06-11 02:05:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> create table t1(t1key integer);
sqlite> .quit
File shows up!
For future readers, this is from SQLite.org website and works for me:
SQLite version 3.8.5 2014-05-29 12:36:14
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open ex1.db
sqlite>
The example above causes the database file named "ex1.db" to be opened and used, and created if it does not previously exist. You might want to use a full pathname to ensure that the file is in the directory that you think it is in. Use forward-slashes as the directory separator character. In other words use "c:/work/ex1.db", not "c:\work\ex1.db".
Visit http://www.sqlite.org/cli.html for more details.
Hope this will help..
Go to command prompt
type cd \ (press enter)
cd sqlite (press enter)
sqlite3 mydb.db(press enter)
.databases(press enter)
That's strange, simply typing
sqlite3 test.db
Should create the sqlite database it does for me, does it show any errors?
When it use that command I get the following output
$ sqlite3 test.db
SQLite version 3.6.12
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>
Which is the sqlite command line interface
In response to your edit you need to type sqlite3 test.db from your command line not from inside the sqlite prompt.
When you type it in your command prompt it will create the database in the directory where you are working and open the sqlite command prompt.
I faced same issue and then I logged into command prompt with Run as Administrator privilege and the issue is gone.
Hope this helps someone.
What you have is incorrect:
SQLite version 3.6.22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> sqlite3 test.db
...>
In particular the line : sqlite> sqlite3 test.db. It also does not match your statement: when type "sqlite3 test.db" I get,.
The command should be as follows:
sqlite3 test.db
This will then give you the following output:
SQLite version 3.20.0 2017-08-01 13:24:15
Enter ".help" for usage hints.
sqlite>
After this, you can must type .databases which will show you the full path to
your file and then type .quit to exit out of this prompt. If you don't do at
least .database command the file does not get created.
The file will be created in the directory you entered the
command.
This is clearly showns here: sqlite tutoriaspoint
Hope this helps.
You can create a SQLite database file using Linux: touch db_name.db
If you want to execute commands such as create table you have to open databse file first using: .open db_name.db
I also observed the same.
When I type sqlite3 test.db, I enter the sqlite3 prompt.
Then checked the databases using command .databases. Yahooo!! It shows the test.db and also in the directory I can see the test.db file.
I think the db file is visible only after we do any operation in the new database file. (Not sure)
It sounds like your Environment Variables haven't been setup to use SQLite3. Now I'm not sure of your OS, but here's how to set it under WinXP:
- Start -> Right-click 'My Computer'
- Select 'Properties'
- Select the 'Advanced' tab
- Click 'Environment Variables'
- (Under 'System Variables') Select 'Path'
- Click 'Edit'
- (Under 'Variable Value') Go to the end of the line and enter the path to your sqlite3.exe (minus sqlite3.exe) For example: C:\bin\sqlite3\;
And that's it! But remember that each path under 'Variable Value' is separated by a semi-colon, so make sure there is one before your new path.