VesselWheel

sqlite3 설치 및 데이터 생성 본문

Xcode Study

sqlite3 설치 및 데이터 생성

JasonYang 2023. 10. 26. 19:48

맥os SQLite 설치 방법

안드로이드나 ios 개발할  sqlite 많이 쓰는데요
안드로이드나 애플에서 앱 개발시 공식적으로 sqlite 지원하고 있습니다

오늘은 MacOS에 sqlite3 를 설치하는 방법에 대해서 알아볼게요

sqlite는 sql + light 로 sql 의 기능들을 경량화하여 
기능들을 뺀 것들이 있습니다
그 점을 감안하시고 설치해주세요

% brew install sqlite3
brew install sqlite3

맥에서는 리눅스의 yum, apt 를 대신해서 brew를 사용합니다
보통 맥에서는 기본으로 sqlite가 설치되어 있어 already installed 라고 이미 설치되어 있다고
알려줄거예요, 이미 설치 되어 있으신 분은 

% brew upgrade sqlite

위 명령어를 사용해 업그레이드 해 주세요

% brew list sqlite3

sqlite3 가 제대로 설치 되었는지 확인해 줍니다

% sqlite3 test.db

sqlite3 "생성할 DB이름" 

 

terminal 참고 코드 

Last login: Thu Oct 26 16:10:59 on ttys000

 

(base) jasonyang@Jasonui-MacBookPro ~ % brew install sqlite3

==> Downloading https://formulae.brew.sh/api/formula.jws.json

######################################################################### 100.0%

==> Downloading https://formulae.brew.sh/api/cask.jws.json

######################################################################### 100.0%

sqlite  is already installed but outdated (so it will be upgraded).

==> Downloading https://ghcr.io/v2/homebrew/core/sqlite/manifests/3.43.2

######################################################################### 100.0%

==> Fetching sqlite

==> Downloading https://ghcr.io/v2/homebrew/core/sqlite/blobs/sha256:96e50e9d331

######################################################################### 100.0%

==> Pouring sqlite--3.43.2.sonoma.bottle.tar.gz

==> Caveats

sqlite is keg-only, which means it was not symlinked into /usr/local,

because macOS already provides this software and installing another version in

parallel can cause all kinds of trouble.

 

If you need to have sqlite first in your PATH, run:

  echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.zshrc

 

For compilers to find sqlite you may need to set:

  export LDFLAGS="-L/usr/local/opt/sqlite/lib"

  export CPPFLAGS="-I/usr/local/opt/sqlite/include"

 

For pkg-config to find sqlite you may need to set:

  export PKG_CONFIG_PATH="/usr/local/opt/sqlite/lib/pkgconfig"

==> Summary

🍺  /usr/local/Cellar/sqlite/3.43.2: 11 files, 4.6MB

==> Running `brew cleanup sqlite`...

Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.

Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

Removing: /usr/local/Cellar/sqlite/3.43.1... (11 files, 4.6MB)

Removing: /Users/jasonyang/Library/Caches/Homebrew/sqlite--3.43.1... (2.2MB)

Warning: The following dependents of upgraded formulae are outdated but will not

be upgraded because they are not bottled:

  game-porting-toolkit

==> Upgrading 2 dependents of upgraded formula:

Disable this behaviour by setting HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK.

Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

python@3.11 3.11.5 -> 3.11.6, pygobject3 3.46.0 -> 3.46.0_1

==> Downloading https://ghcr.io/v2/homebrew/core/python/3.11/manifests/3.11.6

######################################################################### 100.0%

==> Downloading https://ghcr.io/v2/homebrew/core/pygobject3/manifests/3.46.0_1

######################################################################### 100.0%

==> Fetching dependencies for pygobject3: gettext, libx11, cairo, python-setuptools and python@3.12

==> Downloading https://ghcr.io/v2/homebrew/core/gettext/manifests/0.22.3

######################################################################### 100.0%

==> Fetching gettext

==> Downloading https://ghcr.io/v2/homebrew/core/gettext/blobs/sha256:1853891cc1

######################################################################### 100.0%

==> Downloading https://ghcr.io/v2/homebrew/core/libx11/manifests/1.8.7

######################################################################### 100.0%

==> Fetching libx11

==> Downloading https://ghcr.io/v2/homebrew/core/libx11/blobs/sha256:be011cbeead

######################################################################### 100.0%

==> Downloading https://ghcr.io/v2/homebrew/core/cairo/manifests/1.18.0

######################################################################### 100.0%

==> Fetching cairo

==> Downloading https://ghcr.io/v2/homebrew/core/cairo/blobs/sha256:18232de7a188

######################################################################### 100.0%

==> Downloading https://ghcr.io/v2/homebrew/core/python-setuptools/manifests/68.

######################################################################### 100.0%

==> Fetching python-setuptools

==> Downloading https://ghcr.io/v2/homebrew/core/python-setuptools/blobs/sha256:

######################################################################### 100.0%

==> Downloading https://ghcr.io/v2/homebrew/core/python/3.12/manifests/3.12.0-1

######################################################################### 100.0%

==> Fetching python@3.12

==> Downloading https://ghcr.io/v2/homebrew/core/python/3.12/blobs/sha256:bb924b

######################################################################### 100.0%

==> Fetching pygobject3

==> Downloading https://ghcr.io/v2/homebrew/core/pygobject3/blobs/sha256:cc4a132

######################################################################### 100.0%

==> Upgrading pygobject3

  3.46.0 -> 3.46.0_1 

 

==> Installing dependencies for pygobject3: gettext, libx11, cairo, python-setuptools and python@3.12

==> Installing pygobject3 dependency: gettext

==> Downloading https://ghcr.io/v2/homebrew/core/gettext/manifests/0.22.3

Already downloaded: /Users/jasonyang/Library/Caches/Homebrew/downloads/c39063a94fdbad486d1b2e0bb3832dc7d7d7533dd55e07a10322af82dc115e44--gettext-0.22.3.bottle_manifest.json

==> Pouring gettext--0.22.3.sonoma.bottle.tar.gz

🍺  /usr/local/Cellar/gettext/0.22.3: 2,040 files, 21.4MB

==> Installing pygobject3 dependency: libx11

==> Downloading https://ghcr.io/v2/homebrew/core/libx11/manifests/1.8.7

Already downloaded: /Users/jasonyang/Library/Caches/Homebrew/downloads/4d15c929e0532c9a908dcb7d562929ecc5dd3a0a0cd4c19cf50683c06282fd7f--libx11-1.8.7.bottle_manifest.json

==> Pouring libx11--1.8.7.sonoma.bottle.tar.gz

🍺  /usr/local/Cellar/libx11/1.8.7: 1,042 files, 6.9MB

==> Installing pygobject3 dependency: cairo

==> Downloading https://ghcr.io/v2/homebrew/core/cairo/manifests/1.18.0

Already downloaded: /Users/jasonyang/Library/Caches/Homebrew/downloads/1b8b7f19e38cb0e029497dfe0ad3f3557f605025c5575bdfe86c17b889c6e6d1--cairo-1.18.0.bottle_manifest.json

==> Pouring cairo--1.18.0.sonoma.bottle.tar.gz

🍺  /usr/local/Cellar/cairo/1.18.0: 52 files, 2.1MB

==> Installing pygobject3 dependency: python-setuptools

==> Downloading https://ghcr.io/v2/homebrew/core/python-setuptools/manifests/68.

Already downloaded: /Users/jasonyang/Library/Caches/Homebrew/downloads/151f47f6f59597343d42954b5ffea4de6be29e18a9d7a07fc2386a3ad08752dc--python-setuptools-68.2.2.bottle_manifest.json

==> Pouring python-setuptools--68.2.2.sonoma.bottle.tar.gz

🍺  /usr/local/Cellar/python-setuptools/68.2.2: 245 files, 2.9MB

==> Installing pygobject3 dependency: python@3.12

==> Downloading https://ghcr.io/v2/homebrew/core/python/3.12/manifests/3.12.0-1

Already downloaded: /Users/jasonyang/Library/Caches/Homebrew/downloads/1d0e36aa721b7d8acd766516670f97049b43de5aeca6a81a88fbc208ff4eff5f--python@3.12-3.12.0-1.bottle_manifest.json

==> Pouring python@3.12--3.12.0.sonoma.bottle.1.tar.gz

==> /usr/local/Cellar/python@3.12/3.12.0/bin/python3.12 -Im ensurepip

==> /usr/local/Cellar/python@3.12/3.12.0/bin/python3.12 -Im pip install -v --no-

🍺  /usr/local/Cellar/python@3.12/3.12.0: 3,193 files, 63MB

==> Installing pygobject3

==> Pouring pygobject3--3.46.0_1.sonoma.bottle.tar.gz

🍺  /usr/local/Cellar/pygobject3/3.46.0_1: 97 files, 2.2MB

==> Running `brew cleanup pygobject3`...

Removing: /usr/local/Cellar/pygobject3/3.46.0... (67 files, 1.6MB)

==> Checking for dependents of upgraded formulae...

==> No broken dependents found!

==> Caveats

==> sqlite

sqlite is keg-only, which means it was not symlinked into /usr/local,

because macOS already provides this software and installing another version in

parallel can cause all kinds of trouble.

 

If you need to have sqlite first in your PATH, run:

  echo 'export PATH="/usr/local/opt/sqlite/bin:$PATH"' >> ~/.zshrc

 

For compilers to find sqlite you may need to set:

  export LDFLAGS="-L/usr/local/opt/sqlite/lib"

  export CPPFLAGS="-I/usr/local/opt/sqlite/include"

 

For pkg-config to find sqlite you may need to set:

  export PKG_CONFIG_PATH="/usr/local/opt/sqlite/lib/pkgconfig"

(base) jasonyang@Jasonui-MacBookPro ~ % brew list sqlite3

/usr/local/Cellar/sqlite/3.43.2/bin/sqlite3

/usr/local/Cellar/sqlite/3.43.2/include/ (2 files)

/usr/local/Cellar/sqlite/3.43.2/lib/libsqlite3.0.dylib

/usr/local/Cellar/sqlite/3.43.2/lib/pkgconfig/sqlite3.pc

/usr/local/Cellar/sqlite/3.43.2/lib/ (2 other files)

/usr/local/Cellar/sqlite/3.43.2/share/man/man1/sqlite3.1

(base) jasonyang@Jasonui-MacBookPro ~ % .help

zsh: command not found: .help

(base) jasonyang@Jasonui-MacBookPro ~ % Auto-updated Homebrew!

zsh: command not found: Auto-updated

(base) jasonyang@Jasonui-MacBookPro ~ % brew list sqlite3

/usr/local/Cellar/sqlite/3.43.2/bin/sqlite3

/usr/local/Cellar/sqlite/3.43.2/include/ (2 files)

/usr/local/Cellar/sqlite/3.43.2/lib/libsqlite3.0.dylib

/usr/local/Cellar/sqlite/3.43.2/lib/pkgconfig/sqlite3.pc

/usr/local/Cellar/sqlite/3.43.2/lib/ (2 other files)

/usr/local/Cellar/sqlite/3.43.2/share/man/man1/sqlite3.1

(base) jasonyang@Jasonui-MacBookPro ~ % sqlite3 test.db

SQLite version 3.41.2 2023-03-22 11:56:21

Enter ".help" for usage hints.

sqlite> .help

.archive ...             Manage SQL archives

.auth ON|OFF             Show authorizer callbacks

.backup ?DB? FILE        Backup DB (default "main") to FILE

.bail on|off             Stop after hitting an error.  Default OFF

.binary on|off           Turn binary output on or off.  Default OFF

.cd DIRECTORY            Change the working directory to DIRECTORY

.changes on|off          Show number of rows changed by SQL

.check GLOB              Fail if output since .testcase does not match

.clone NEWDB             Clone data into NEWDB from the existing database

.connection [close] [#]  Open or close an auxiliary database connection

.databases               List names and files of attached databases

.dbconfig ?op? ?val?     List or change sqlite3_db_config() options

.dbinfo ?DB?             Show status information about the database

.dump ?OBJECTS?          Render database content as SQL

.echo on|off             Turn command echo on or off

.eqp on|off|full|...     Enable or disable automatic EXPLAIN QUERY PLAN

.excel                   Display the output of next command in spreadsheet

.exit ?CODE?             Exit this program with return-code CODE

.expert                  EXPERIMENTAL. Suggest indexes for queries

.explain ?on|off|auto?   Change the EXPLAIN formatting mode.  Default: auto

.filectrl CMD ...        Run various sqlite3_file_control() operations

.fullschema ?--indent?   Show schema and the content of sqlite_stat tables

.headers on|off          Turn display of headers on or off

.help ?-all? ?PATTERN?   Show help text for PATTERN

.import FILE TABLE       Import data from FILE into TABLE

.imposter INDEX TABLE    Create imposter table TABLE on index INDEX

.indexes ?TABLE?         Show names of indexes

.limit ?LIMIT? ?VAL?     Display or change the value of an SQLITE_LIMIT

.lint OPTIONS            Report potential schema issues.

.load FILE ?ENTRY?       Load an extension library

.log FILE|off            Turn logging on or off.  FILE can be stderr/stdout

.mode MODE ?OPTIONS?     Set output mode

.nonce STRING            Suspend safe mode for one command if nonce matches

.nullvalue STRING        Use STRING in place of NULL values

.once ?OPTIONS? ?FILE?   Output for the next SQL command only to FILE

.open ?OPTIONS? ?FILE?   Close existing database and reopen FILE

.output ?FILE?           Send output to FILE or stdout if FILE is omitted

.parameter CMD ...       Manage SQL parameter bindings

.print STRING...         Print literal STRING

.progress N              Invoke progress handler after every N opcodes

.prompt MAIN CONTINUE    Replace the standard prompts

.quit                    Stop interpreting input stream, exit if primary.

.read FILE               Read input from FILE or command output

.recover                 Recover as much data as possible from corrupt db.

.restore ?DB? FILE       Restore content of DB (default "main") from FILE

.save ?OPTIONS? FILE     Write database to FILE (an alias for .backup ...)

.scanstats on|off|est    Turn sqlite3_stmt_scanstatus() metrics on or off

.schema ?PATTERN?        Show the CREATE statements matching PATTERN

.selftest ?OPTIONS?      Run tests defined in the SELFTEST table

.separator COL ?ROW?     Change the column and row separators

.sha3sum ...             Compute a SHA3 hash of database content

.shell CMD ARGS...       Run CMD ARGS... in a system shell

.show                    Show the current values for various settings

.stats ?ARG?             Show stats or turn stats on or off

.system CMD ARGS...      Run CMD ARGS... in a system shell

.tables ?TABLE?          List names of tables matching LIKE pattern TABLE

.testcase NAME           Begin redirecting output to 'testcase-out.txt'

.testctrl CMD ...        Run various sqlite3_test_control() operations

.timeout MS              Try opening locked tables for MS milliseconds

.timer on|off            Turn SQL timer on or off

.trace ?OPTIONS?         Output each SQL statement as it is run

.version                 Show source, library and compiler versions

.vfsinfo ?AUX?           Information about the top-level VFS

.vfslist                 List all available VFSes

.vfsname ?AUX?           Print the name of the VFS stack

.width NUM1 NUM2 ...     Set minimum column widths for columnar output

sqlite> 

 

sqlite3 DBbrowser

https://1mini2.tistory.com/78

'Xcode Study' 카테고리의 다른 글

UITableViewCell  (0) 2023.11.24
고차함수(Map, filter, reduce)  (1) 2023.11.21
서버 구축 vapor  (0) 2023.10.26
assert / guard  (0) 2023.10.19
Generic  (0) 2023.10.19