Основы использования sqlite3 в php

Users who downloaded SQLite also downloaded:

We are happy to recommend you programs like SQLite that other users liked. Software similar to SQLite:

subarticle1.0 
1.1

Use our script to submit your articles to

Download
Development Software

User rating

Apex SQL SSIS Compare 
2008.03

Stop wasting time looking through SQL Code and find your information

Download
Development Software

User rating

BrownRecluse 
1.62

The ultimate utility for running and writing web scripts

Download
Development Software

User rating

Barcode .NET Windows Forms Control DLL 
11.10

Generate Barcodes easily from any .Net Application

Download
Development Software

User rating

Asynchronous API

The asynchronous library uses the Task Parallel Library (TPL). As such, normal use of objects, and the and keywords
will work for you.

Once you have defined your entity, you can automatically generate tables by calling :

// Get an absolute path to the database file
var databasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "MyData.db");

var db = new SQLiteAsyncConnection(databasePath);

await db.CreateTableAsync<Stock>();

Console.WriteLine("Table created!");

You can insert rows in the database using . If the table contains an auto-incremented primary key, then the value for that key will be available to you after the insert:

var stock = new Stock()
{
	Symbol = "AAPL"
};

await db.InsertAsync(stock);

Console.WriteLine("Auto stock id: {0}", stock.Id);

Similar methods exist for and .

Querying for data is most straightforwardly done using the method. This will return an instance back, whereupon
you can add predicates for constraining via WHERE clauses and/or adding ORDER BY. The database is not physically touched until one of the special
retrieval methods — , , or — is called.

var query = db.Table<Stock>().Where(s => s.Symbol.StartsWith("A"));

var result = await query.ToListAsync();

foreach (var s in result)
	Console.WriteLine("Stock: " + s.Symbol);

There are a number of low-level methods available. You can also query the database directly via the method. Over and above the change
operations provided by etc you can issue methods to change sets of data directly within the database.

Another helpful method is . This allows you to return a scalar value from the database easily:

var count = await db.ExecuteScalarAsync<int>("select count(*) from Stock");

Console.WriteLine(string.Format("Found '{0}' stock items.", count));

Download & Install SQLite Package Installer

Installation packages available for Windows 10 users:

From the SQLite official website in the download section. The following screenshot allows you to download different SQLite’s installation packages for Windows:

The command line shell program:

The highlighted download package is called the Command-Line Program (CLP). CLP is a command line application that let you access the SQLite database management system and all the features of the SQLite. Using CLP, you can create and manage the SQLite database. And it is the tool that we will use throughout the tutorial.

  • 32-bit DLL(x86): The SQLite Database system core library for x86 platforms.
  • 64-bit DLL (x64): The SQLite Database system core library for x64 platforms.

Installing the Command-Line Program (CLP) on your machine:

In the following steps, you will find the steps for how to install the Command-Line Program (CLP) on your machine:

Step 1) Download the highlighted download package from the previous image to your PC. It is a «zip» file.

Step 2) Extract the zip file. You will find the «sqlite3.exe» in the extracted file as following:

Step 3) Open My Computer, and double-click the partition «C» to navigate to it:

Step 4) Create a new directory «sqlite»:

Step 5) Copy the file «sqlite3.exe» into it. This is what we will use through the tutorials to run SQLite queries:

However, there are some other packages for different purposes. They are not required. But you might need it if you are using a different OS than Windows you can get the Linux or Mac OS version of SQLite.

Also, you can get the documentation or source code from there if you wish. You can also get the API for Windows Phone 8 or .Net and other programming languages.

Here are some other different packages for different purposes:

  • The Source Code and some alternative Source Code Formats – The complete source code that made up the SQLite.
  • The documentation – The documentation of the SQLite as HTML pages. It is the same online documentation, but downloadable as HTML page so that you can open them offline.
  • Precompiled Binaries for Linux.
  • Precompiled Binaries for Mac OS X (x86).
  • Precompiled Binaries for Windows Phone 8 – SDK and components to develop an application for Windows Phone 8 that uses SQLite databases.
  • Precompiled Binaries for Windows Runtime – SDK and other components for developing an application to connect to SQLite databases for the Windows Runtime platforms.
  • Precompiled Binaries for .NET – these are some set of DLLs and .NET libraries that you can use them from .NET application to connect to SQLite databases.

How It All Fits Together

Years of effort have gone into optimizating SQLite, both
for small size and high performance. And optimizations tend to result in
complex code. So there is a lot of complexity in the current SQLite
implementation. It will not be the easiest library in the world to hack.

Key files:

  • sqlite.h.in — This file defines the public interface to the SQLite
    library. Readers will need to be familiar with this interface before
    trying to understand how the library works internally.

  • sqliteInt.h — this header file defines many of the data objects
    used internally by SQLite. In addition to «sqliteInt.h», some
    subsystems have their own header files.

  • parse.y — This file describes the LALR(1) grammar that SQLite uses
    to parse SQL statements, and the actions that are taken at each step
    in the parsing process.

  • vdbe.c — This file implements the virtual machine that runs
    prepared statements. There are various helper files whose names
    begin with «vdbe». The VDBE has access to the vdbeInt.h header file
    which defines internal data objects. The rest of SQLite interacts
    with the VDBE through an interface defined by vdbe.h.

  • where.c — This file (together with its helper files named
    by «where*.c») analyzes the WHERE clause and generates
    virtual machine code to run queries efficiently. This file is
    sometimes called the «query optimizer». It has its own private
    header file, whereInt.h, that defines data objects used internally.

  • btree.c — This file contains the implementation of the B-Tree
    storage engine used by SQLite. The interface to the rest of the system
    is defined by «btree.h». The «btreeInt.h» header defines objects
    used internally by btree.c and not published to the rest of the system.

  • pager.c — This file contains the «pager» implementation, the
    module that implements transactions. The «pager.h» header file
    defines the interface between pager.c and the rest of the system.

  • os_unix.c and os_win.c — These two files implement the interface
    between SQLite and the underlying operating system using the run-time
    pluggable VFS interface.

  • shell.c.in — This file is not part of the core SQLite library. This
    is the file that, when linked against sqlite3.a, generates the
    «sqlite3.exe» command-line shell. The «shell.c.in» file is transformed
    into «shell.c» as part of the build process.

  • tclsqlite.c — This file implements the Tcl bindings for SQLite. It
    is not part of the core SQLite library. But as most of the tests in this
    repository are written in Tcl, the Tcl language bindings are important.

  • test.c* — Files in the src/ folder that begin with «test» go into
    building the «testfixture.exe» program. The testfixture.exe program is
    an enhanced Tcl shell. The testfixture.exe program runs scripts in the
    test/ folder to validate the core SQLite code. The testfixture program
    (and some other test programs too) is build and run when you type
    «make test».

  • ext/misc/json1.c — This file implements the various JSON functions
    that are build into SQLite.

There are many other source files. Each has a succinct header comment that
describes its purpose and role within the larger system.

SQLite Studio – Manager and Administration

There are lots of SQLite management tools that make working with SQLite databases easier. Instead of creating and managing databases using a command line, these tools provide a set of GUI tools that let you create and manage the database.

The official SQLite website has dozens of such tools listed; you can view them from here: SQLite Management Tools. Here is the recommended one

SQLite Studio: It is a portable tool that doesn’t require an installation. It supports both SQLite3 and SQLite2.  You can easily import and export data to various formats like CSV, HTML, PDF, JSON. Its open source and supports Unicode.

Using MSVC

On Windows, all applicable build products can be compiled with MSVC.
First open the command prompt window associated with the desired compiler
version (e.g. «Developer Command Prompt for VS2013»). Next, use NMAKE
with the provided «Makefile.msc» to build one of the supported targets.

For example:

There are several build options that can be set via the NMAKE command
line. For example, to build for WinRT, simply add «FOR_WINRT=1» argument
to the «sqlite3.dll» command line above. When debugging into the SQLite
code, adding the «DEBUG=1» argument to one of the above command lines is
recommended.

How to contribute

GitHub website

The most efficient way to help and contribute to this wrapper project is to
use the tools provided by GitHub:

  • please fill bug reports and feature requests here: https://github.com/SRombauts/SQLiteCpp/issues
  • fork the repository, make some small changes and submit them with pull-request

Coding Style Guidelines

The source code use the CamelCase naming style variant where:

  • type names (class, struct, typedef, enums…) begin with a capital letter
  • files (.cpp/.h) are named like the class they contain
  • function and variable names begin with a lower case letter
  • member variables begin with a ‘m’, function arguments begin with a ‘a’, booleans with a ‘b’, pointers with a ‘p’
  • each file, class, method and member variable is documented using Doxygen tags

Source install

To skip searching for pre-compiled binaries, and force a build from source, use

The sqlite3 module depends only on libsqlite3. However, by default, an internal/bundled copy of sqlite will be built and statically linked, so an externally installed sqlite3 is not required.

If you wish to install against an external sqlite then you need to pass the argument to wrapper:

If building against an external sqlite3 make sure to have the development headers available. Mac OS X ships with these by default. If you don’t have them installed, install the package with your package manager, e.g. for Debian/Ubuntu. Make sure that you have at least >= 3.6.

Note, if building against homebrew-installed sqlite on OS X you can do:

By default the node-gyp install will use as part of the installation. A
different python executable can be specified on the command line.

This uses the npm_config_python config, so values in .npmrc will be honoured:

History

This program was developed originally by Mauricio Piacentini
(@piacentini) from Tabuleiro Producoes, as
the Arca Database Browser. The original version was used as a free companion
tool to the Arca Database Xtra, a commercial product that embeds SQLite
databases with some additional extensions to handle compressed and binary data.

Pete Morgan (@daffodil) created an initial
project on GitHub with the code in 2012, where several contributors fixed and
improved pieces over the years. René Peinthor (@rp-)
and Martin Kleusberg (@MKleusberg) then
became involved, and have been the main driving force from that point. Justin
Clift (@justinclift) helps out with testing
on OSX, and started the new github.com/sqlitebrowser organisation on GitHub.

In September 2014, the project was renamed to «DB Browser for SQLite», to
avoid confusion with an existing application called «Database Browser».

Software Review

A database management program

Like the MySQL program, SQLite is a database management program that is easy to use and very popular with businesses and individuals. SQLite was written in the C programming language and was first released in the year 2000. SQLite has released its source code into the public domain, which means that anyone who wishes can access and edit the source code, improving and tweaking the program or creating add-ons and plug-ins as they see fit. SQLite is a standard and very easy to use regional database management program that is more streamlined and perhaps easier to use than others. It only has partial support for Triggers and has limited ALTER TABLE support, but it can handle complex queries. SQLite also comes preloaded with support for a huge number of programming languages, from the widely used C, C++, C-Sharp, Java, PHP and Perl, to the lesser used Haskell, Livecode, Pike, Curl, Common Lisp, Free Pascal, D, Clipper and more. There are very few programming languages that the SQLite database management program does not support.

Download

What it is

DB Browser for SQLite (DB4S) is a high quality, visual, open source tool to
create, design, and edit database files compatible with SQLite.

DB4S is for users and developers who want to create, search, and edit
databases. DB4S uses a familiar spreadsheet-like interface, and complicated SQL commands do not have to be learned.

Controls and wizards are available for users to:

  • Create and compact database files
  • Create, define, modify and delete tables
  • Create, define, and delete indexes
  • Browse, edit, add, and delete records
  • Search records
  • Import and export records as text
  • Import and export tables from/to CSV files
  • Import and export databases from/to SQL dump files
  • Issue SQL queries and inspect the results
  • Examine a log of all SQL commands issued by the application
  • Plot simple graphs based on table or query data

Архитектура

Движок БД представляет библиотеку, с которой программа компонуется и SQLite становится составной частью программы. Вся БД хранится в единственном стандартном файле на машине, на которой исполняется программа.

Несколько процессов или потоков могут одновременно без каких-либо проблем читать данные из одной базы. Запись в базу можно осуществить только в том случае, если никаких других запросов в данный момент не обслуживается; в противном случае попытка записи оканчивается неудачей, и в программу возвращается код ошибки. Другим вариантом развития событий является автоматическое повторение попыток записи в течение заданного интервала времени.

Загрузка данных в буфер виджета GtkTreeView

Когда мы подключились к баз данных, мы можем загрузить строки БД в буфер виджета GtkTreeView. Сам буфер мы задаем строчкой:

GtkListStore *buffer; // Буфер таблицы

1 GtkListStore*buffer;// Буфер таблицы

Загрузку данных выполняет следующий код:

// Цикл по SQL-запросу и запись в буфер таблицы
while((rc = sqlite3_step(stmt)) == SQLITE_ROW)
{
gtk_list_store_append (buffer, &iter);
gtk_list_store_set (buffer, &iter,
C_NUM, sqlite3_column_int(stmt, C_NUM),
C_NAME, sqlite3_column_text(stmt, C_NAME),
C_OKLAD, (guint) sqlite3_column_int(stmt, C_OKLAD),
-1);
}

1
2
3
4
5
6
7
8
9
10

// Цикл по SQL-запросу и запись в буфер таблицы

while((rc=sqlite3_step(stmt))==SQLITE_ROW)

{

gtk_list_store_append(buffer,&iter);

gtk_list_store_set(buffer,&iter,

C_NUM,sqlite3_column_int(stmt,C_NUM),

C_NAME,sqlite3_column_text(stmt,C_NAME),

C_OKLAD,(guint)sqlite3_column_int(stmt,C_OKLAD),

-1);

}

Здесь мы в цикле перебираем строки запроса и заполняем ячейки таблицы значениями полей из базы данных.

Using MSVC

On Windows, all applicable build products can be compiled with MSVC.
First open the command prompt window associated with the desired compiler
version (e.g. «Developer Command Prompt for VS2013»). Next, use NMAKE
with the provided «Makefile.msc» to build one of the supported targets.

For example:

There are several build options that can be set via the NMAKE command
line. For example, to build for WinRT, simply add «FOR_WINRT=1» argument
to the «sqlite3.dll» command line above. When debugging into the SQLite
code, adding the «DEBUG=1» argument to one of the above command lines is
recommended.

Создание базы данных

После создания соединения с SQLite, файл БД создается автоматически, при условии его отсутствия. Этот файл создается на диске, но также можно создать базу данных в оперативной памяти, используя параметр «:memory:» в методе connect. При этом база данных будет называется инмемори.

Рассмотрим приведенный ниже код, в котором создается БД с блоками try, except и finally для обработки любых исключений:

Сначала импортируется модуль sqlite3, затем определяется функция с именем sql_connection. Внутри функции определен блок try, где метод connect() возвращает объект соединения после установления соединения.

Затем определен блок исключений, который в случае каких-либо исключений печатает сообщение об ошибке. Если ошибок нет, соединение будет установлено, тогда скрипт распечатает текст «Connection is established: Database is created in memory».

Далее производится закрытие соединения в блоке finally. Закрытие соединения необязательно, но это хорошая практика программирования, позволяющая освободить память от любых неиспользуемых ресурсов.

Using SQLCipher

The database key is set in the passed to the connection constructor:

var options = new SQLiteConnectionString(databasePath, true,
	key: "password");
var encryptedDb = new SQLiteAsyncConnection(options);

If you need set pragmas to control the encryption, actions can be passed to the connection string:

var options2 = new SQLiteConnectionString (databasePath, true,
	key: "password",
	preKeyAction: db => db.Execute("PRAGMA cipher_default_use_hmac = OFF;"),
	postKeyAction: db => db.Execute ("PRAGMA kdf_iter = 128000;"));
var encryptedDb2 = new SQLiteAsyncConnection (options2);

Compiling

First create a directory in which to place
the build products. It is recommended, but not required, that the
build directory be separate from the source directory. Cd into the
build directory and then from the build directory run the configure
script found at the root of the source tree. Then run «make».

For example:

See the makefile for additional targets.

The configure script uses autoconf 2.61 and libtool. If the configure
script does not work out for you, there is a generic makefile named
«Makefile.linux-gcc» in the top directory of the source tree that you
can copy and edit to suit your needs. Comments on the generic makefile
show what changes are needed.

Getting started

Installation

To use this wrapper, you need to add the SQLiteC++ source files from the src/ directory
in your project code base, and compile/link against the sqlite library.

The easiest way to do this is to add the wrapper as a library.
The «CMakeLists.txt» file defining the static library is provided in the root directory,
so you simply have to add_subdirectory(SQLiteCpp) to you main CMakeLists.txt
and link to the «SQLiteCpp» wrapper library.

Example for Linux:

add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/thirdparty/SQLiteCpp)

include_directories(
  ${CMAKE_CURRENT_LIST_DIR}/thirdparty/SQLiteCpp/include
)

add_executable(main src/main.cpp)
target_link_libraries(main
  SQLiteCpp
  sqlite3
  pthread
  dl
  )

Thus this SQLiteCpp repository can be directly used as a Git submodule.
See the SQLiteCpp_Example side repository for a standalone «from scratch» example.

Under Debian/Ubuntu/Mint Linux, you can install the libsqlite3-dev package if you don’t want to use the embedded sqlite3 library.

Building example and unit-tests:

Use git to clone the repository. Then init and update submodule «googletest».

git clone https://github.com/SRombauts/SQLiteCpp.git
cd SQLiteCpp
git submodule init
git submodule update

Using SQLiteCpp on a system-wide installation

If you installed this package to your system, a file will be generated & installed to your system.
This file lets you link against the SQLiteCpp library for use in your Cmake project.

Here’s an example of using this in your CMakeLists.txt

# You can optionally define a minimum version in this call
find_package(SQLiteCpp REQUIRED)
# For this example, lets say you created an target with add_executable (or add_library) called "my_target"
# You can optionally declare PUBLIC or PRIVATE linkage here, depending on your needs.
target_link_libraries(my_target PRIVATE SQLiteCpp)

CMake and tests

A CMake configuration file is also provided for multi-platform support and testing.

Typical generic build for MS Visual Studio under Windows (from build.bat):

mkdir build
cd build

cmake ..        # cmake .. -G "Visual Studio 16 2019"    # for Visual Studio 2019
@REM Generate a Visual Studio solution for latest version found
cmake -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON ..

@REM Build default configuration (ie 'Debug')
cmake --build .

@REM Build and run tests
ctest --output-on-failure

Generating the Linux Makefile, building in Debug and executing the tests (from build.sh):

mkdir Debug
cd Debug

# Generate a Makefile for GCC (or Clang, depanding on CC/CXX envvar)
cmake -DSQLITECPP_BUILD_EXAMPLES=ON -DSQLITECPP_BUILD_TESTS=ON ..

# Build (ie 'make')
cmake --build .

# Build and run unit-tests (ie 'make test')
ctest --output-on-failure

Troubleshooting

Under Linux, if you get multiple linker errors like «undefined reference to sqlite3_xxx»,
it’s that you lack the «sqlite3» library: install the libsqlite3-dev package.

#define SQLITE_ENABLE_COLUMN_METADATA

Continuous Integration

This project is continuously tested under Ubuntu Linux with the gcc and clang compilers
using the Travis CI community service with the above CMake building and testing procedure.
It is also tested in the same way under Windows Server 2012 R2 with Visual Studio 2013 compiler
using the AppVeyor continuous integration service.

Detailed results can be seen online:

Thread-safety

This SQLiteC++ wrapper does no add any locks (no mutexes) nor any other thread-safety mechanism
above the SQLite library itself, by design, for lightness and speed.

Thus, SQLiteC++ naturally supports the «Multi Thread» mode of SQLite:
«In this mode, SQLite can be safely used by multiple threads
provided that no single database connection is used simultaneously in two or more threads.»

But SQLiteC++ does not support the fully thread-safe «Serialized» mode of SQLite,
because of the way it shares the underlying SQLite precompiled statement
in a custom shared pointer (See the inner class «Statement::Ptr»).

Version Control

If you are reading this on GitHub or some other Git repository or service,
then you are looking at a mirror. The names of check-ins and
other artifacts in a Git mirror are different from the official
names for those objects. The offical names for check-ins are
found in a footer on the check-in comment for authorized mirrors.
The official check-in name can also be seen in the file
in the root of the tree. Always use the official name, not the
Git-name, when communicating about an SQLite check-in.

If you pulled your SQLite source code from a secondary source and want to
verify its integrity, there are hints on how to do that in the
section below.

Compiling

First create a directory in which to place
the build products. It is recommended, but not required, that the
build directory be separate from the source directory. Cd into the
build directory and then from the build directory run the configure
script found at the root of the source tree. Then run «make».

For example:

See the makefile for additional targets.

The configure script uses autoconf 2.61 and libtool. If the configure
script does not work out for you, there is a generic makefile named
«Makefile.linux-gcc» in the top directory of the source tree that you
can copy and edit to suit your needs. Comments on the generic makefile
show what changes are needed.

Synchronous API

Once you have defined your entity, you can automatically generate tables in your database by calling :

// Get an absolute path to the database file
var databasePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "MyData.db");

var db = new SQLiteConnection(databasePath);
db.CreateTable<Stock>();
db.CreateTable<Valuation>();

You can insert rows in the database using . If the table contains an auto-incremented primary key, then the value for that key will be available to you after the insert:

public static void AddStock(SQLiteConnection db, string symbol) {
	var stock = new Stock() {
		Symbol = symbol
	};
	db.Insert(stock);
	Console.WriteLine("{0} == {1}", stock.Symbol, stock.Id);
}

Similar methods exist for and .

The most straightforward way to query for data is using the method. This can take predicates for constraining via WHERE clauses and/or adding ORDER BY clauses:

var query = db.Table<Stock>().Where(v => v.Symbol.StartsWith("A"));

foreach (var stock in query)
	Console.WriteLine("Stock: " + stock.Symbol);

You can also query the database at a low-level using the method:

public static IEnumerable<Valuation> QueryValuations (SQLiteConnection db, Stock stock) {
	return db.Query<Valuation> ("select * from Valuation where StockId = ?", stock.Id);
}

The generic parameter to the method specifies the type of object to create for each row. It can be one of your table classes, or any other class whose public properties match the column returned by the query. For instance, we could rewrite the above query as:

public class Val
{
	public decimal Money { get; set; }
	public DateTime Date { get; set; }
}

public static IEnumerable<Val> QueryVals (SQLiteConnection db, Stock stock) {
	return db.Query<Val> ("select \"Price\" as \"Money\", \"Time\" as \"Date\" from Valuation where StockId = ?", stock.Id);
}

You can perform low-level updates of the database using the method.

Version Control

If you are reading this on GitHub or some other Git repository or service,
then you are looking at a mirror. The names of check-ins and
other artifacts in a Git mirror are different from the official
names for those objects. The offical names for check-ins are
found in a footer on the check-in comment for authorized mirrors.
The official check-in name can also be seen in the file
in the root of the tree. Always use the official name, not the
Git-name, when communicating about an SQLite check-in.

If you pulled your SQLite source code from a secondary source and want to
verify its integrity, there are hints on how to do that in the
section below.

Examples

The first sample demonstrates how to query a database and get results:

try
{
    // Open a database file
    SQLite::Database    db("example.db3");
    
    // Compile a SQL query, containing one parameter (index 1)
    SQLite::Statement   query(db, "SELECT * FROM test WHERE size > ?");
    
    // Bind the integer value 6 to the first parameter of the SQL query
    query.bind(1, 6);
    
    // Loop to execute the query step by step, to get rows of result
    while (query.executeStep())
    {
        // Demonstrate how to get some typed column value
        int         id      = query.getColumn();
        const char* value   = query.getColumn(1);
        int         size    = query.getColumn(2);
        
        std::cout << "row: " << id << ", " << value << ", " << size << std::endl;
    }
}
catch (std::exception& e)
{
    std::cout << "exception: " << e.what() << std::endl;
}

The second sample shows how to manage a transaction:

try
{
    SQLite::Database    db("transaction.db3", SQLite::OPEN_READWRITE|SQLite::OPEN_CREATE);

    db.exec("DROP TABLE IF EXISTS test");

    // Begin transaction
    SQLite::Transaction transaction(db);

    db.exec("CREATE TABLE test (id INTEGER PRIMARY KEY, value TEXT)");

    int nb = db.exec("INSERT INTO test VALUES (NULL, \"test\")");
    std::cout << "INSERT INTO test VALUES (NULL, \"test\")\", returned " << nb << std::endl;

    // Commit transaction
    transaction.commit();
}
catch (std::exception& e)
{
    std::cout << "exception: " << e.what() << std::endl;
}

How to handle assertion in SQLiteC++:

Exceptions shall not be used in destructors, so SQLiteC++ uses SQLITECPP_ASSERT() to check for errors in destructors.
If you don’t want assert() to be called, you have to enable and define an assert handler as shown below,
and by setting the flag SQLITECPP_ENABLE_ASSERT_HANDLER when compiling the lib.

#ifdef SQLITECPP_ENABLE_ASSERT_HANDLER
namespace SQLite
{
/// definition of the assertion handler enabled when SQLITECPP_ENABLE_ASSERT_HANDLER is defined in the project (CMakeList.txt)
void assertion_failed(const char* apFile, const long apLine, const char* apFunc, const char* apExpr, const char* apMsg)
{
    // Print a message to the standard error output stream, and abort the program.
    std::cerr << apFile << ":" << apLine << ":" << " error: assertion failed (" << apExpr << ") in " << apFunc << "() with message \"" << apMsg << "\"\n";
    std::abort();
}
}
#endif

Releases

  • Version 3.12.0 released — 2020-06-16
  • Version 3.11.2 released — 2019-04-03
  • Version 3.11.1 released — 2019-02-18
  • Version 3.11.0 released — 2019-02-07
  • Version 3.10.1 released — 2017-09-20
  • Version 3.10.0 released — 2017-08-20
  • Version 3.9.1 released — 2016-10-03
  • Version 3.9.0 released — 2016-08-24
  • Version 3.8.0 released — 2015-12-25
  • Version 3.7.0 released — 2015-06-14
  • Version 3.6.0 released — 2015-04-27
  • Version 3.5.1 released — 2015-02-08
  • Version 3.5.0 released — 2015-01-31
  • Version 3.4.0 released — 2014-10-29
  • Version 3.3.1 released — 2014-08-31 — Project renamed from «SQLite Database Browser»
  • Version 3.3.0 released — 2014-08-24
  • Version 3.2.0 released — 2014-07-06
  • Version 3.1.0 released — 2014-05-17
  • Version 3.0.3 released — 2014-04-28
  • Version 3.0.2 released — 2014-02-12
  • Version 3.0.1 released — 2013-12-02
  • Version 3.0 released — 2013-09-15
  • Version 3.0rc1 released — 2013-09-09 — Project now on GitHub
  • Version 2.0b1 released — 2009-12-10 — Based on Qt4.6
  • Version 1.2 released — 2005-04-05
  • Version 1.1 released — 2004-07-20
  • Version 1.01 released — 2003-10-02
  • Version 1.0 released to public domain — 2003-08-19

Building for node-webkit

To build node-sqlite3 for node-webkit:

  1. Build the module with the custom flags of , , and :

NODE_WEBKIT_VERSION="0.8.6"npm install sqlite3 --build-from-source --runtime=node-webkit --target_arch=ia32 --target=$(NODE_WEBKIT_VERSION)

You can also run this command from within a checkout:

npm install --build-from-source --runtime=node-webkit --target_arch=ia32 --target=$(NODE_WEBKIT_VERSION)

Remember the following:

  • You must provide the right flag. is needed to target 32bit node-webkit builds, while will target 64bit node-webkit builds (if available for your platform).

  • After the package is built for node-webkit it cannot run in the vanilla Node.js (and vice versa).

    For example, npm test of the node-webkit’s package would fail.

Comparison of Alternative Programs:

EasyStruct 4.5 Enterprise

Paradox viewer

DataRoamer

myLittleAdmin for SQL Server 2005

Description Manage and monitor your data and documents Direct and fast read any Paradox table Simple, fast, powerful GUI database viewer. Web-based MS SQL 2005 administration tool
Rating
Downloads 148 106 68 9
Price $ 89.99 $ 20 $ 39 $ 590
File Size 11.50 MB 1.00 MB 0.80 MB 1.25 MB

Download

Download

Download

Download

Users who downloaded SQLite also downloaded:

We are happy to recommend you programs like SQLite that other users liked. Software similar to SQLite:

subarticle1.0 
1.1

Use our script to submit your articles to

Download
Development Software

User rating

Apex SQL SSIS Compare 
2008.03

Stop wasting time looking through SQL Code and find your information

Download
Development Software

User rating

BrownRecluse 
1.62

The ultimate utility for running and writing web scripts

Download
Development Software

User rating

Barcode .NET Windows Forms Control DLL 
11.10

Generate Barcodes easily from any .Net Application

Download
Development Software

User rating

Please Contribute!

This is an open source project that welcomes contributions/suggestions/bug reports from those who use it. If you have any ideas on how to improve the library, please post an issue here on GitHub. Please check out the How to Contribute.

Example Time!

Please consult the Wiki for, ahem, complete documentation.

The library contains simple attributes that you can use to control the construction of tables. In a simple stock program, you might use:

public class Stock
{
	
	public int Id { get; set; }
	public string Symbol { get; set; }
}

public class Valuation
{
	
	public int Id { get; set; }
	
	public int StockId { get; set; }
	public DateTime Time { get; set; }
	public decimal Price { get; set; }
}

Once you’ve defined the objects in your model you have a choice of APIs. You can use the «synchronous API» where calls
block one at a time, or you can use the «asynchronous API» where calls do not block. You may care to use the asynchronous
API for mobile applications in order to increase responsiveness.

Both APIs are explained in the two sections below.

Оцените статью
Рейтинг автора
5
Материал подготовил
Андрей Измаилов
Наш эксперт
Написано статей
116
Добавить комментарий