- Как установить SQLite и браузер SQLite в Ubuntu
- Установка SQLite в Ubuntu
- Создание базы данных и таблицы SQLite
- Установка браузера SQLite в Ubuntu
- Удаление SQLite и браузера SQLite
- How to Install and Basic SQLite Use on Linux
- Installing Sqlite
- Create Database
- Create Table
- Inserting Data
- Fetching data
- Special commands to sqlite3(dot -commands)
- Writing results to a file
- Библиотека sqlite для linux
- SQLite Download Page
- Build Product Names and Info
- Source Code Repositories
Как установить SQLite и браузер SQLite в Ubuntu
SQLite — это легкая, небольшая и автономная СУБД. Популярные базы данных, такие как MySql, PostgreSQL и т. д. работают как клиент — сервер, и у них есть специальный процесс, выполняющий и контролирующий все аспекты работы базы данных.
А SQLite не имеет запущенного процесса и не имеет модели клиент — серверной. SQLite DB — это просто файл с расширениями .sqlite3 .sqlite .db. Каждый язык программирования имеет библиотеку для поддержки SQLite.
SQLite используется в таких программах как:
- Веб-браузеры (Chrome, Safari, Firefox).
- MP3-плееры, приставки и электронные гаджеты.
- Устройства на Android, Mac, Windows, iOS и iPhone.
Областей где используется SQLite очень много. Например каждый смартфон в мире имеет сотни файлов базы данных SQLite. На наш взгляд это довольно большое количество. Пока приступить к установке db.
Установка SQLite в Ubuntu
Настройка и установка SQLite очень проста, по сравнению с другими популярными базами данных, такими как MySql, Postgresql и т. д. Во-первых, обновите apt-cache, выполнив следующую команду.
Теперь проверьте, есть ли какие нибудь пакеты SQLite, которые доступны в репозитории apt. Для этого выполнив следующую команду.
Чтобы установить SQLite, выполните следующую команду.
Вы можете проверить установку, для этого запустите сеанс sqlite. Это можно сделать выполнив следующую команду.
Как видно из приведенного выше изображения, SQLite3 успешно установлен и работает с версией 3.33.0..
Создание базы данных и таблицы SQLite
База данных хранится в виде файла в вашей файловой системе. Вы можете создать базу данных при запуске сеанса sqlite, указав имя базы данных в качестве аргумента. Если БД доступна, она откроет базу данных, если нет, то создаст новую базу данных.
Если мы не передаем имя БД в качестве аргумента, то создается временная база данных в памяти, которая будет удалена после завершения сеанса. Здесь у меня нет никакой базы данных, поэтому я создам новую БД, упомянув имя db в качестве аргумента. Как только вы подключитесь к сеансу, вы можете запустить команду .databases, чтобы увидеть, какой файл прикреплен к базе данных.
$ sqlite3 /home/tecmint/test # создание тестовой базы данных в /home/tecmint
sqlite> .databases #команда для того чтобы увидеть, какой сеанс базы данных подключен
Теперь давайте создадим пример таблицы, выполнив следующие запросы.
# create table
sqlite> CREATE TABLE employee(
Name String,
age Int);
# Insert records
sqlite> insert into employee(Name, age)
VALUES (‘Tom’,25),
(‘Mark’,40),
(‘Steve’,35);
Вы можете запустить команду .tables, чтобы вывести список таблиц в базе данных.
sqlite> .tables # отображает список таблиц в базе данных
sqlite> .headers on # включить столбец для печати
sqlite> SELECT * FROM employee; # выбор записи из таблицы
Установка браузера SQLite в Ubuntu
Теперь, когда мы как установили и настроили sqlite3, мы также установим sqlite browser. Это простой графический инструмент для управления базами данных sqlite.
$ sudo apt install sqlitebrowser -y
Вы можете запустить приложение из меню «Пуск» или из терминала. Для запуска браузера из терминала выполните следующую команду.
Удаление SQLite и браузера SQLite
Для удаления SQLite, так и SQLite browser потребуется выполнить следующую команду.
$ sudo apt —purge remove sqlite3 sqlitebrowser
Вот и все. Если у вас есть какие-либо отзывы или советы, пожалуйста, используйте раздел комментариев, чтобы опубликовать их.
Источник
How to Install and Basic SQLite Use on Linux
In this article, We will see how to install SQLite (relational database) with its basic operations. What if I tell you that SQLite is likely used more than all other database engines combined. Yes, You heard it right. It is the most widely deployed database in the world with millions and billions of copies.
The reason behind this popularity is some unique characteristics that are unusual and which makes it different from many other SQL database engines like MySQL, PostgreSQL, Oracle, Microsoft SQL Server, etc. Let’s get started with it. First, We will install it on Linux and later on cover basic database operations.
Installing Sqlite
To install on your Debian based (Ubuntu, Debian, etc.) machine execute below commands.
To install on your RPM-based (RHEL, CentOS, Fedora etc.) machine execute below commands.
You may also install SQlite using the DNF package manager:
Now Open a terminal and Execute «sqlite3», you will see the following lines with prompt.
The very first line shows the version and release date and time of sqlite3.
The second line tells to enter «.help» for instructions.
.help command list all the meta commands and their descriptions. These meta commands are also called «dot» commands because they are preceded by a dot.
Put «.help» to prompt
Before explaining these dot commands, let’s see some of the basic database operations.
First run «.quit» command to end the session.
Create Database
Execute below command on shell prompt.
It will create «example.db» (You can put your choice of name in place of «example.db») database file ( if not exists). If exists then open the database contained in the file.
The difference between «sqlite3» and «sqlite3 dbname.db» command is the first one will create a temporary database for the session and will expire when the session is closed.
Create Table
Let’s create a student table with attributes:
reg_no int(4)
Name varchar(20)
Marks int(3)
enter the following commands in terminal
It will create a student table with above attributes.
You can see the list of tables in the selected database by .table command
There is only one table student in my case.
You can also see the schema of the table using .schema table_name
Inserting Data
Let’s insert 3 records in the table
101, pradip, 87
102, Avinash, 86
103, Rakesh, 90
Enter the following command one by one
Fetching data
You can fetch data from table with select statement
It shows the result in default mode (list).
You can change the mode with .mode command
Enter .mode column to prompt and then perform select query. It will show the result in a column format.
Delete, Alter, Drop etc have same syntax as sql.
Special commands to sqlite3(dot -commands)
We saw «.help» commands list all the dot commands. Let’s understand some other important commands.
Shows name of database selected.
List the tables in the selected database.
Shows the current settings
You can show attribute name in query result by running .header ON|OFF command
The Program is able to show the results of a query in eight different formats: «csv», «column»,»html»,»insert», «line», «list», «tabs», «tcl»..mode command is use to switch between these output formats.
You can use .separator command to change separator.
sqlite> .separator —
> select * from student;
reg_no-name-marks
101-Pradip-87
102-Avinash-86
103-Rakesh-91
Writing results to a file
by default, It sends query results to standard output.
you can change this using «.output» and «.once» commands.
Just put the name of an output file as an argument to .output and all subsequent query results will be written to that file.
Or use the .once the command with file name if you want only the result of next query to be redirected.
We have successfully installed SQLite on Linux with basic operations. These operations are only a few out of all available. We can’t cover all of them in this article. If you find any difficulties in an installation or in any command, Let me know in the comment section.
Источник
Библиотека sqlite для linux
SQLite Download Page
Pre-release Snapshots | |||
sqlite-snapshot-202110061004.tar.gz (2.85 MiB) | The amalgamation source code, the command-line shell source code, configure/make scripts for unix, and a Makefile.msc for Windows. See the change log or the timeline for more information. (sha3: 4b7f5677757f6988660bf648fc24a56fb8ecef11834b9b911be8f1ddd1ec253d) | ||
Source Code | |||
sqlite-amalgamation-3360000.zip (2.36 MiB) | C source code as an amalgamation, version 3.36.0. (sha3: d25609210ec93b3c8c7da66a03cf82e2c9868cfbd2d7d866982861855e96f972) | ||
sqlite-autoconf-3360000.tar.gz (2.84 MiB) | C source code as an amalgamation. Also includes a «configure» script and TEA makefiles for the TCL Interface. (sha3: fdc699685a20284cb72efe3e3ddfac58e94d8ffd5b229a8235d49265aa776678) | ||
Documentation | |||
sqlite-doc-3360000.zip (11.71 MiB) | Documentation as a bundle of static HTML files. (sha3: 7f33c45e581988b350f6fbcd90cfe3a9d18ee831b36c52d1cc402978125c9616) | ||
Precompiled Binaries for Android | |||
sqlite-android-3360000.aar (3.13 MiB) | A precompiled Android library containing the core SQLite together with appropriate Java bindings, ready to drop into any Android Studio project. (sha3: e68d7c04e26e56dd957a741f346667e227d641b9bd60f1571163ef0fcd715f4a) | ||
Precompiled Binaries for Linux | |||
sqlite-tools-linux-x86-3360000.zip (2.07 MiB) | A bundle of command-line tools for managing SQLite database files, including the command-line shell program, the sqldiff program, and the sqlite3_analyzer program. (sha3: edfefce9a2b9b076102dd2d27f4b03eeafa1291088ea84ea7baee3e5333386b8) | ||
Precompiled Binaries for Mac OS X (x86) | |||
sqlite-tools-osx-x86-3360000.zip (1.47 MiB) | A bundle of command-line tools for managing SQLite database files, including the command-line shell program, the sqldiff program, and the sqlite3_analyzer program. (sha3: edd862b3ad642bdf7802d5db14c778c0642059ea035462aa526ea062deac9961) | ||
Precompiled Binaries for Windows | |||
sqlite-dll-win32-x86-3360000.zip (542.87 KiB) | 32-bit DLL (x86) for SQLite version 3.36.0. (sha3: dbcc568711f3f3e12a32e5abfca652f1c38eb71ccedd81874e9669708f9c71c8) | ||
sqlite-dll-win64-x64-3360000.zip (880.05 KiB) | 64-bit DLL (x64) for SQLite version 3.36.0. (sha3: af88804c191758431458611b8214b466348df17415b2671641793cef53ae762a) | ||
sqlite-tools-win32-x86-3360000.zip (1.82 MiB) | 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. (sha3: 38a0b9d0d41487b76c86f8d45c0e05def2011ac9e48a331dde79bb28087d9eda) | ||
Universal Windows Platform | |||
sqlite-uwp-3360000.vsix (7.81 MiB) | VSIX package for Universal Windows Platform development using Visual Studio 2015. (sha3: 0f65a3afc73714e8d334fae281d856678f81d1aa7457e826dbc41091a6956373) | ||
Precompiled Binaries for Windows Phone 8 | |||
sqlite-wp80-winrt-3360000.vsix (5.07 MiB) | A complete VSIX package with an extension SDK and all other components needed to use SQLite for application development with Visual Studio 2012 targeting Windows Phone 8.0. (sha3: 3bb473a89bf1921f7d0d1ef1d3e5f92039c030426b21027136a9d83326266ba9) | ||
sqlite-wp81-winrt-3360000.vsix (5.12 MiB) | A complete VSIX package with an extension SDK and all other components needed to use SQLite for application development with Visual Studio 2013 targeting Windows Phone 8.1. (sha3: f9ce4e45ede2bf8f435538d8fbf60e4f1099ec79eb8d880518b893f451dc2a0c) | ||
Precompiled Binaries for Windows Runtime | |||
sqlite-winrt-3360000.vsix (7.70 MiB) | A complete VSIX package with an extension SDK and all other components needed to use SQLite for WinRT application development with Visual Studio 2012. (sha3: 234222e81bbdb2d1b0fc84a2301d55e5273cf30cfb7a54c8508137b686589192) | ||
sqlite-winrt81-3360000.vsix (7.71 MiB) | A complete VSIX package with an extension SDK and all other components needed to use SQLite for WinRT 8.1 application development with Visual Studio 2013. (sha3: f66664517fe73a3c873011aa51fa4c2b950548d1d00f84f825f029441ca61915) | ||
Precompiled Binaries for .NET | |||
System.Data.SQLite | Visit the System.Data.SQLite.org website and especially the download page for source code and binaries of SQLite for .NET. | ||
Alternative Source Code Formats | |||
sqlite-src-3360000.zip (12.38 MiB) | Snapshot of the complete (raw) source tree for SQLite version 3.36.0. See How To Compile SQLite for usage details. (sha3: 346d3edbfc21dddae6367c31c7470f321538fa60791b1a225af4f3a84fec0ecc) | ||
sqlite-preprocessed-3360000.zip (2.58 MiB) | Preprocessed C sources for SQLite version 3.36.0. (sha3: 86008b545ac7ae63e7e22628f71712483ec67817cbbf355795a3ad1342cdbdf5) |
Build Product Names and Info
Build products are named using one of the following templates:
- sqlite-product—version.zip
- sqlite-product—version.tar.gz
- sqlite-product—os—cpu—version.zip
- sqlite-product—date.zip
Templates (1) and (2) are used for source-code products. Template (1) is used for generic source-code products and templates (2) is used for source-code products that are generally only useful on unix-like platforms. Template (3) is used for precompiled binaries products. Template (4) is used for unofficial pre-release «snapshots» of source code.
The version is encoded so that filenames sort in order of increasing version number when viewed using «ls». For version 3.X.Y the filename encoding is 3XXYY00. For branch version 3.X.Y.Z, the encoding is 3XXYYZZ.
The date in template (4) is of the form: YYYYMMDDHHMM
For convenient, script-driven extraction of the downloadable file URLs and associated information, an HTML comment is embedded in this page’s source. Its first line (sans leading tag) reads:
Download product data for scripts to read
Source Code Repositories
The SQLite source code is maintained in three geographically-dispersed self-synchronizing Fossil repositories that are available for anonymous read-only access. Anyone can view the repository contents and download historical versions of individual files or ZIP archives of historical check-ins. You can also clone the entire repository.
See the How To Compile SQLite page for additional information on how to use the raw SQLite source code. Note that a recent version of Tcl is required in order to build from the repository sources. The amalgamation source code files (the «sqlite3.c» and «sqlite3.h» files) build products and are not contained in raw source code tree.
There is a GitHub mirror at
The documentation is maintained in separate Fossil repositories located at:
Источник