![]() Type in SQL statements (terminated by a semicolon), press "Enter" and the SQL will be executed.įor example, to create a new SQLite database named "ex1" with a single table named "tbl1", you might do this: $ sqlite3 ex1 When started, the sqlite3 program will show a brief banner message then prompt you to enter SQL. If no database file is specified, a temporary database is created, then deleted when the "sqlite3" program exits. If the file does not exist, a new database file with the given name will be created automatically. ![]() To start the sqlite3 program, just type "sqlite3" optionally followed by the name the file that holds the SQLite database. This document provides a brief introduction on how to use the sqlite3 program. The SQLite project provides a simple command-line utility named sqlite3 (or sqlite3.exe on windows) that allows the user to manually enter and execute SQL statements against an SQLite database. The C language interface to SQLite Version 2 ![]() Upgrading SQLite, Backwards Compatibility Locking And Concurrency In SQLite Version 3 NULL Handling in SQLite Versus Other Database Engines It’s as simple as that.An Introduction To The SQLite C/C++ InterfaceĬ-language Interface Specification for SQLite Maybe this would not make a full-blown application but a very powerful, easy to deploy configuration database for a legacy program launcher. The SQL can get as complicated as you like.Ī single data file ( mydatabase.sqlite), one (or more) batch files ( person.bat and phone.bat) and a single executable ( sqlite3.exe) and you have a fulling working application. Now we have the details of the person with the id of 3. Now for the results C:\sqlite>person.bat 3 bat files C:\sqlite>type person.batĮcho SELECT name from person where id=%1 | sqlite3.exe mydatabase.sqliteĮcho SELECT phone from person where id=%1 | sqlite3.exe mydatabase.sqlite To verify this we can take a quick look inside the. ![]() phone.bat will return the corresponding phone number. person.bat will return the name of the person for the given id. The echo command is used to pass the Sql select statement to the database. What we have done is create two batch files that each take a single parameter (%1) which in this case will need to be the id of the person we are looking for when called. echo SELECT name from person where id=^%1^ ^| sqlite3.exe mydatabase.sqlite > person.batĮcho SELECT phone from person where id=^%1^ ^| sqlite3.exe mydatabase.sqlite > phone.bat bat files from the DOS command line for this example. We will create some batch files that can look up a person’s details given an integer id. Create a table and some test dataĮnter the following into the Sqlite shell. Then enter cmd to open a DOS command shell and press OK.Ĭd to the directory that sqlite is in or specify the full path, then put the name of the new (to be created database file), I will call mine mydatabase.sqlite. To run the command line shell (in windows) you can click on Start->Run… C:\sqlite\ Run the Sqlite shell and create a database file Unzip the file into a convenient directory.Įg. The filename should something like: sqlite-shell-win3400.zipĭownload and unzip the file and you will find a the executable file: sqlite3.exe The version we are looking for will be under the heading “ Precompiled Binaries For Windows“. Sqlite runs on numerous operating systems. You will need to download a single executable file, the Sqlite command line shell from the Sqlite download page: One added advantage over all the others is the fact that Sqlite and its code is released into the public domain. For now I will only provide an Sqlite example because it is the new kid on the block and is, up to now, still a little less known than the other (possibly dated) alternatives. ![]() There are also other alternatives, each with their slant on query languages. When talking about alternatives Berkley DB springs to mind. I hope once you have seen it in action you will think up new and interesting ways of applying the same techniques in your own projects.īefore I continue I will say that this is not the only database that can perform this sort of thing. I won’t go into all the details of Sqlite but merely show you a start to end set of steps to get you going. … if you have ever wanted or needed to access a flexible database from a DOS batch file … One will often use a VBS or Perl script to glue together or bootstrap complex or outdated software.Įven so if you have ever wanted or needed to access a flexible database from a DOS batch file, but though the overhead of installing a full-blown database that understood SQL (so you don’t need to learn some wacky new syntax), now is your chance. They are also not the most modern or full featured. DOS batch files do not have the most flexible scripting syntax. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |