COW-database & SQLITE usefull scripts
Posted: Thu Jul 14, 2022 4:33 am
Hello all,
i discovered that COW uses the sqlite database format so i made some simple queries for people to play with.
Maybe somebody has some other usefull sql-queries that we can use.
I think Query-3 is handy to create a custom made Ebook.
First create from youre mainbase a pgn-file with the opening you want to create.
Create a new Ebook and import the pgn-file.
If needed, Import additional pgn-files in the new created Ebook.
Run query-3 to import the already existing position evaluations.
Export end-positions to an EPD-file
Analyse the EPD-file with engine
Backsolve the complete file and the new Ebook is complete.
Additional you maybe want to import the new Ebook in youre mainbase and backsolve that also.
My mainbook sofar, which contains all openings : https://wetransfer.com/downloads/bca995 ... 758/fb170b
this book is completely analysed with stockfish-15 at depth 25 or more.
I encourage other people to make there books also available so we can create 1 big analysed ebook.
Q U E R I E S :
always backup youre existing files before executing the queries, you never know !!
blahblahblah -- garbage command to prevent the complete script runnning by accident
-- in both bases the tablenames and fields are identical, we use main. to refer to our mainbase
-- ChessU is the file that will be updated
-- main is the COW database with the correct position assessments and comments
-- just select a Query and run the selected query lines
-- Query-1 : DISPLAY THE RECORDS IN BOTH FILES
attach database 'c:\COW-Bases\ChessU.4MD' as ChessU;
select fboard, fnumeric_assessment from ChessU.tmainPosition;
--limit 5; -- display all records -field from ChessU
select fboard, fnumeric_assessment from main.tmainPosition;
--limit 5: -- display all record -field from the main database
-- Query-2 : displays all records that have the same position in both bases
-- optional is : where the value = -32768 (initual value)
attach database 'c:\COW-Bases\ChessU.4MD' as ChessU;
SELECT ChessU.tmainPosition.fboard,
ChessU.tMainPosition.fnumeric_assessment,
main.tMainPosition.fnumeric_assessment
FROM ChessU.tMainPosition,
main.tMainPosition
WHERE ChessU.tMainPosition.fboard = main.tMainPosition.fboard
--AND ChessU.tmainPosition.fnumeric_assessment = -32768 -- optional
;
-- Query-3 : update ChessU.tmainPosition.fnumeric_assessment
-- with the value in the main book
attach database 'c:\COW-Bases\ChessU.4MD' as ChessU;
UPDATE ChessU.tMainPosition
SET fnumeric_assessment =
( SELECT main.tMainPosition.fnumeric_assessment
FROM main.tMainPosition
WHERE ChessU.tMainPosition.fboard = main.tMainPosition.fboard
)
;
UPDATE ChessU.tMainPosition
SET fnumeric_assessment = -32768
WHERE fnumeric_assessment is NULL
;
-- Query-4 : change/delete comments from a database
attach database 'c:\COW-Bases\ChessU.4MD' as ChessU;
UPDATE ChessU.tMainPosition
SET fcomments = '' ; -- blanks all comments
Vacuum ChessU;
-- Query-5 : change/delete comments from main database
-- and clean up the database
-- *******************************************************************************
-- ** Be carefull : this deletes all comments in youre main base !!!!!!!!!!!!!! *
-- *******************************************************************************
UPDATE tMainPosition
SET fcomments = '' ;
vacuum main;
-- Query-6 : Cleanup youre main database, removes empty/deleted records
-- attached databases cant be cleaned this way
vacuum main;
i discovered that COW uses the sqlite database format so i made some simple queries for people to play with.
Maybe somebody has some other usefull sql-queries that we can use.
I think Query-3 is handy to create a custom made Ebook.
First create from youre mainbase a pgn-file with the opening you want to create.
Create a new Ebook and import the pgn-file.
If needed, Import additional pgn-files in the new created Ebook.
Run query-3 to import the already existing position evaluations.
Export end-positions to an EPD-file
Analyse the EPD-file with engine
Backsolve the complete file and the new Ebook is complete.
Additional you maybe want to import the new Ebook in youre mainbase and backsolve that also.
My mainbook sofar, which contains all openings : https://wetransfer.com/downloads/bca995 ... 758/fb170b
this book is completely analysed with stockfish-15 at depth 25 or more.
I encourage other people to make there books also available so we can create 1 big analysed ebook.
Q U E R I E S :
always backup youre existing files before executing the queries, you never know !!
blahblahblah -- garbage command to prevent the complete script runnning by accident
-- in both bases the tablenames and fields are identical, we use main. to refer to our mainbase
-- ChessU is the file that will be updated
-- main is the COW database with the correct position assessments and comments
-- just select a Query and run the selected query lines
-- Query-1 : DISPLAY THE RECORDS IN BOTH FILES
attach database 'c:\COW-Bases\ChessU.4MD' as ChessU;
select fboard, fnumeric_assessment from ChessU.tmainPosition;
--limit 5; -- display all records -field from ChessU
select fboard, fnumeric_assessment from main.tmainPosition;
--limit 5: -- display all record -field from the main database
-- Query-2 : displays all records that have the same position in both bases
-- optional is : where the value = -32768 (initual value)
attach database 'c:\COW-Bases\ChessU.4MD' as ChessU;
SELECT ChessU.tmainPosition.fboard,
ChessU.tMainPosition.fnumeric_assessment,
main.tMainPosition.fnumeric_assessment
FROM ChessU.tMainPosition,
main.tMainPosition
WHERE ChessU.tMainPosition.fboard = main.tMainPosition.fboard
--AND ChessU.tmainPosition.fnumeric_assessment = -32768 -- optional
;
-- Query-3 : update ChessU.tmainPosition.fnumeric_assessment
-- with the value in the main book
attach database 'c:\COW-Bases\ChessU.4MD' as ChessU;
UPDATE ChessU.tMainPosition
SET fnumeric_assessment =
( SELECT main.tMainPosition.fnumeric_assessment
FROM main.tMainPosition
WHERE ChessU.tMainPosition.fboard = main.tMainPosition.fboard
)
;
UPDATE ChessU.tMainPosition
SET fnumeric_assessment = -32768
WHERE fnumeric_assessment is NULL
;
-- Query-4 : change/delete comments from a database
attach database 'c:\COW-Bases\ChessU.4MD' as ChessU;
UPDATE ChessU.tMainPosition
SET fcomments = '' ; -- blanks all comments
Vacuum ChessU;
-- Query-5 : change/delete comments from main database
-- and clean up the database
-- *******************************************************************************
-- ** Be carefull : this deletes all comments in youre main base !!!!!!!!!!!!!! *
-- *******************************************************************************
UPDATE tMainPosition
SET fcomments = '' ;
vacuum main;
-- Query-6 : Cleanup youre main database, removes empty/deleted records
-- attached databases cant be cleaned this way
vacuum main;