<commit_before>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" EXECUTE -- OTHER WINDOW
nmap <buffer> <F2> :call SQLITE_ScratchQuery("", "")<CR>
nmap <buffer> <F3> :call SQLITE_ScratchQuery("-column", "")<CR>
nmap <buffer> <F4> :call SQLITE_ScratchQuery("-line", "")<CR>

" EXPLAIN
nmap <buffer> ,e :call SQLITE_ScratchQuery("-column", "explain")<CR>

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" FUNCTIONS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! SQLITE_ScratchQuery(type, prefix)
  normal yip
  let l:query=Strip(@0)

  if !exists("g:db_name")
    call SQLITE_Database_Vars()
  end

  if a:type == '-column'
    Scratch "sqlite3 -header " . g:db_name . " '" . l:query . "' | sed -e 's/ /_/g' -e 's/|/ /g' | column -t | sed 's/_/ /g'"
  else
    Scratch "sqlite3 -header " . a:type . " " . g:db_name . " '" . l:query . "'"
  end
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! SQLITE_Database_Vars()
  if !exists("g:db_name")
    let g:db_name     = ""
  end

  let g:db_name     = input("database: ", g:db_name, "file")
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
<commit_msg>non-stupid conversion of sqlite result into formatted output<commit_after>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

" EXECUTE -- OTHER WINDOW
nmap <buffer> <F2> :call SQLITE_ScratchQuery("", "")<CR>
nmap <buffer> <F3> :call SQLITE_ScratchQuery("-column", "")<CR>
nmap <buffer> <F4> :call SQLITE_ScratchQuery("-line", "")<CR>

" EXPLAIN
nmap <buffer> ,e :call SQLITE_ScratchQuery("-column", "explain")<CR>

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" FUNCTIONS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! SQLITE_ScratchQuery(type, prefix)
  normal yip
  let l:query=Strip(@0)

  if !exists("g:db_name")
    call SQLITE_Database_Vars()
  end

  if a:type == '-column'
    Scratch "sqlite3 -header -nullvalue null " . g:db_name . " '" . l:query . "' | column -t -s \\|"
  else
    Scratch "sqlite3 -header -nullvalue null " . a:type . " " . g:db_name . " '" . l:query . "'"
  end
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
function! SQLITE_Database_Vars()
  if !exists("g:db_name")
    let g:db_name     = ""
  end

  let g:db_name     = input("database: ", g:db_name, "file")
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

{'fraction_non_alphanumeric': 0.37918367346938775, 'fraction_numerical': 0.004897959183673469, 'mean_word_length': 5.142857142857143, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2231011', 'n_tokens_mistral': 1053, 'n_tokens_neox': 1054, 'n_words': 170}