LiteCLI は,コードアシスト機能付きの,SQLite 3 コマンドラインクライアント
目次
Python の URL: http://www.python.org/
インストール手順の詳細は: 別ページで説明している.
コマンドプロンプトを管理者として実行し,次のコマンドを実行.
python -m pip install -U pip setuptools
pip install -U setuptools
python -m pip install -q git+https://github.com/dbcli/litecli.git
litecli
「exit」で終了
exit
Ubuntu では,端末で,次のコマンドを実行.
sudo apt -yV install git
Ubuntu では,端末で,次のコマンドを実行.
sudo apt -yV install python3-setuptools
端末で,次のコマンドを実行.
sudo python3 -m pip install -q git+https://github.com/dbcli/litecli.git
litecli
「exit」で終了
exit
このとき,データベース名として mydb を指定する.SQLite の流儀で,データベース名はファイル名になる.
※ データベース名はなんでも良いが、アルファベットのみを使うのが良い.
litecli mydb
「help」で,ヘルプが表示される.
help
「PRAGMA encoding;」で,エンコーディングが表示される.
pragma encoding;
「exit」で終了.
exit
SQLite3 の説明は http://www.sqlite.org/sqlite.html
ここでの設定
litecli
.open C:/sqlite3/hoge.db
exit
litecli
.open C:/sqlite3/hoge.db
※ テーブル名に日本語を使うとエラーが出る場合がある.
create table order_records (
id integer primary key not null,
year integer not null CHECK ( year > 2008 ),
month integer not null CHECK ( month >= 1 AND month <= 12 ),
day integer not null CHECK ( day >= 1 AND day <= 31 ),
customer_name text not null,
product_name text not null,
unit_price real not null check ( unit_price > 0 ),
qty integer not null default 1 check ( qty > 0 ),
created_at timestamp with time zone not null,
updated_at timestamp with time zone,
check ( ( unit_price * qty ) < 200000 ) );
.tables
begin transaction; insert into order_records (id, year, month, day, customer_name, product_name, unit_price, qty) values( 1, 2020, 7, 26, 'kaneko', 'orange A', 1.2, 10 ); insert into order_records (id, year, month, day, customer_name, product_name, unit_price, qty) values( 2, 2020, 7, 26, 'miyamoto', 'Apple M', 2.5, 2 ); insert into order_records (id, year, month, day, customer_name, product_name, unit_price, qty) values( 3, 2020, 7, 27, 'kaneko', 'orange B', 1.2, 8 ); insert into order_records (id, year, month, day, customer_name, product_name, unit_price) values( 4, 2020, 7, 28, 'miyamoto', 'Apple L', 3 ); commit;
select * from order_records;
exit
pragma については https://www.sqlite.org/pragma.html
SQLite3 のキャッシュサイズは,オープンしたデータベースについて,最大どれだけをメモリに保持するか.「-」が付いているときは,単位は1024バイト.
キャッシュサイズの変更.「-500」のように「-」を付けると,単位は 1024 バイト.単純に「512000」のように書くとバイト単位.
現在接続しているデータベースについてのジャーナルモード.ジャーナルは,トランザクションのロールバックのために用いるもの(SQLite3 の独自用語ではない)
delete, truncate, persiste, memory, wal, off に設定できる.
本サイトは金子邦彦研究室のWebページです.サイトマップは,サイトマップのページをご覧下さい. 本サイト内の検索は,サイト内検索のページをご利用下さい.
問い合わせ先: 金子邦彦(かねこ くにひこ) ![]()