문제

 

Powershell(또는 cmd) 에서 Sqlite로 db연결해서 테이블 확인 중에 에러가 발생했다.

 

 

 원인

 

구글검색으로 찾아보니 여러가지 케이스가 있는 듯하다.

 

그 중에 sqlite.org 사이트 문서에서 찾은 아래의 문장에서 답을 찾을 수 있었다.

 

This error code occurs when you try to do two incompatible things with a database at the same time from the same database connection

이 오류 코드는 동일한 데이터베이스 연결에서 동시에 데이터베이스와 호환되지 않는 두 가지 작업을 수행하려고 할 때 발생합니다.

 

 

 해결

 

원인은 같은 .db 파일을 두곳에서 사용하는데

이미 열어두고 작업하던 DB Browser for SQLite에서 테이블을 만들고 난 후에, 변경사항 저장하기를 하지 않아서 생긴 문제였다.

DB Browser for SQLite에서 변경사항 저장하기 후에 Powershell(또는 cmd)에서 다시 시도하니 문제가 없었다.

 

 

 출처

 

Error Code SQLITE_LOCKED (6): Database Is Locked
This error code occurs when you try to do two incompatible things with a database at the same time from the same database connection. For example, if you are in the middle of a SELECT statement and you try to DROP one of the tables being read by the SELECT, you will get an SQLITE_LOCKED error. Here is an example (using Tcl):

   db eval {SELECT rowid FROM ex1} {
     if {$rowid==10} {
       db eval {DROP TABLE ex1}  ;# will give SQLITE_LOCKED error
     }
   }

 

https://www2.sqlite.org/cvstrac/wiki?p=DatabaseIsLocked 

 

 

+ Recent posts