본문 바로가기

Linux

sqlite3 설치

sqlite 설치

URL : http://sqlite.org/ 

다운로드 버전
소스 버전 sqlite-3.4.2.tar.gz

난 항상 소스이 좋더라~ㅋㅋ(오타쿠인가?ㅡㅡ;;)

README를 읽어보니 설치는 간단하다~ㅋ

설치
tar xzf sqlite.tar.gz
mkdir bld
cd bld
../sqlite-3.4.2/configure
make
~~
./libtool --mode=compile --tag=CC gcc -g -O2 -I. -I../sqlite-3.4.2/src -DNDEBUG   -DTHREADSAFE=0 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -c ../sqlite-3.4.2/src/tclsqlite.c
 gcc -g -O2 -I. -I../sqlite-3.4.2/src -DNDEBUG -DTHREADSAFE=0 -DSQLITE_THREAD_OVERRIDE_LOCK=-1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -c ../sqlite-3.4.2/src/tclsqlite.c  -fPIC -DPIC -o .libs/tclsqlite.o
../sqlite-3.4.2/src/tclsqlite.c:286: warning: initialization from incompatible pointer type
../sqlite-3.4.2/src/tclsqlite.c:296: warning: excess elements in struct initializer
../sqlite-3.4.2/src/tclsqlite.c:296: warning: (near initialization for `IncrblobChannelType')
../sqlite-3.4.2/src/tclsqlite.c: In function `DbUpdateHandler':
../sqlite-3.4.2/src/tclsqlite.c:581: warning: passing arg 3 of `Tcl_ListObjAppendElement' makes pointer from integer without a cast
../sqlite-3.4.2/src/tclsqlite.c: In function `tclSqlFunc':
../sqlite-3.4.2/src/tclsqlite.c:667: warning: passing arg 1 of `Tcl_NewByteArrayObj' discards qualifiers from pointer target type
../sqlite-3.4.2/src/tclsqlite.c:675: warning: assignment makes pointer from integer without a cast
../sqlite-3.4.2/src/tclsqlite.c:733: `Tcl_WideInt' undeclared (first use in this function)
../sqlite-3.4.2/src/tclsqlite.c:733: (Each undeclared identifier is reported only once
../sqlite-3.4.2/src/tclsqlite.c:733: for each function it appears in.)
../sqlite-3.4.2/src/tclsqlite.c:733: parse error before `v'
../sqlite-3.4.2/src/tclsqlite.c:734: `v' undeclared (first use in this function)
../sqlite-3.4.2/src/tclsqlite.c: In function `DbObjCmd':
../sqlite-3.4.2/src/tclsqlite.c:938: warning: passing arg 3 of `Tcl_GetIndexFromObj' from incompatible pointer type
../sqlite-3.4.2/src/tclsqlite.c:1590: warning: passing arg 2 of `Tcl_GetVar2Ex' discards qualifiers from pointer target type
../sqlite-3.4.2/src/tclsqlite.c:1614: `Tcl_WideInt' undeclared (first use in this function)
../sqlite-3.4.2/src/tclsqlite.c:1614: parse error before `v'
../sqlite-3.4.2/src/tclsqlite.c:1615: `v' undeclared (first use in this function)
../sqlite-3.4.2/src/tclsqlite.c:1665: warning: passing arg 1 of `Tcl_NewByteArrayObj' discards qualifiers from pointer target type
../sqlite-3.4.2/src/tclsqlite.c:1673: warning: assignment makes pointer from integer without a cast
../sqlite-3.4.2/src/tclsqlite.c:1953: parse error before `rowid'
../sqlite-3.4.2/src/tclsqlite.c:1958: `rowid' undeclared (first use in this function)
../sqlite-3.4.2/src/tclsqlite.c:2174: warning: passing arg 3 of `Tcl_GetIndexFromObj' from incompatible pointer type
../sqlite-3.4.2/src/tclsqlite.c: In function `DbMain':
../sqlite-3.4.2/src/tclsqlite.c:2346: warning: passing arg 2 of `Tcl_TranslateFileName' discards qualifiers from pointer target type
../sqlite-3.4.2/src/tclsqlite.c:2366: warning: passing arg 2 of `Tcl_CreateObjCommand' discards qualifiers from pointer target type
make: *** [tclsqlite.lo] Error 1
#

이게 먼 소린가?ㅡㅡ;;

tcl관련 에러가 난다..

서버에 tcl/tk에 관한 라이브러리가 없나보다ㅋ

그럼 빼고 하지모ㅋ

../sqlite-3.4.2/configure --help

를 보니 tcl disable 옵션이 있다.

그럼 다시~

../sqlite-3.4.2/configure --disable-tcl

# make clean
# make

OK~ㅋㅋ

# make install

완료~

그럼 sqlite 테스트를 해볼까~^^

# sqlite3
sqlite3: error while loading shared libraries: libsqlite3.so.0: cannot open shared object file: No such file or directory

우씨 또 에러난다.ㅡㅡ;;

shared libraries 로드 하다가 에라난다네..ㅡㅡ;;

그런데 설치한 디렉토리(bld)에서는 정상적으로 된다..ㅡㅡ;;

그냥 쓰자 귀찮다.ㅋㅋ

# ./sqlite3 db/test.db
SQLite version 3.4.2
Enter ".help" for instructions
sqlite> .h
.bail ON|OFF           Stop after hitting an error.  Default OFF
.databases             List names and files of attached databases
.dump ?TABLE? ...      Dump the database in an SQL text format
.echo ON|OFF           Turn command echo on or off
.exit                  Exit this program
.explain ON|OFF        Turn output mode suitable for EXPLAIN on or off.
.header(s) ON|OFF      Turn display of headers on or off
.help                  Show this message
.import FILE TABLE     Import data from FILE into TABLE
.indices TABLE         Show names of all indices on TABLE
.mode MODE ?TABLE?     Set output mode where MODE is one of:
                         csv      Comma-separated values
                         column   Left-aligned columns.  (See .width)
                         html     HTML <table> code
                         insert   SQL insert statements for TABLE
                         line     One value per line
                         list     Values delimited by .separator string
                         tabs     Tab-separated values
                         tcl      TCL list elements
.nullvalue STRING      Print STRING in place of NULL values
.output FILENAME       Send output to FILENAME
.output stdout         Send output to the screen
.prompt MAIN CONTINUE  Replace the standard prompts
.quit                  Exit this program
.read FILENAME         Execute SQL in FILENAME
.schema ?TABLE?        Show the CREATE statements
.separator STRING      Change separator used by output mode and .import
.show                  Show the current values for various settings
.tables ?PATTERN?      List names of tables matching a LIKE pattern
.timeout MS            Try opening locked tables for MS milliseconds
.width NUM NUM ...     Set column widths for "column" mode
sqlite> .database
seq  name             file                                                     
---  ---------------  ----------------------------------------------------------
0    main             ~~/bld/db/test.db                      
sqlite> CREATE TABLE t1(
   ...>   a INTEGER PRIMARY KEY,
   ...>   b INTEGER
   ...> );
sqlite> .tables
t1
sqlite> insert into t1 values ('111','111');
sqlite> insert into t1 values ('222','222');     
sqlite> select * from t1;
111|111
222|222
sqlite>

ㅋㅋ 잘된다ㅋ