---
title: "💭 searching my thoughts locally"
description: "!None"
date: 2024-03-07
published: true
tags:
  - sqlite
  - data
  - blog
  - thought
template: link
---


<!-- embed not found: None -->
![[None]]

First I need to fetch my thoughts from the api, and put it in a local sqlite database using `sqlite-utils`.

``` bash
fthoughts () {
    # fetch thoughts
    curl 'https://thoughts.waylonwalker.com/posts/waylonwalker/?page_size=9999999999' | sqlite-utils insert ~/.config/thoughts/database2.db post --pk=id --alter --ignore -
}
```

Now that I have my posts in a local sqlite database I can use `sqlite-utils` to enable full text search  and populate the full text search on the post table using the title message and tags columns as search.

``` bash
sthoughts () {
    # search thoughts
    # sqlite-utils enable-fts ~/.config/thoughts/database2.db post title message tags
    # sqlite-utils populate-fts ~/.config/thoughts/database2.db post title message tags
    sqlite-utils search ~/.config/thoughts/database2.db post "$*" | ~/git/thoughts/format_thought.py | bat --style=plain --color=always --language=markdown
}

alias st=sthoughts
```

Now I am ready to search my thoughts, which is a tiny blog format that I created mostly for  leaving my own personal comment on web pages, so most of them have a link to some other online content, and their title is based on the authors title.

<img src="https://vhs.charm.sh/vhs-5UMOPkPbr43X3PKi6q1sih.gif" alt="Made with VHS">
<a href="https://vhs.charm.sh">
  <img src="https://stuff.charm.sh/vhs/badge.svg">
</a>


!!! note

    This post is a <a href="/thoughts/" class="wikilink" data-title="Thoughts" data-description="These are generally my thoughts on a web page or some sort of url, except a rare few don&#39;t have a link. These are dual published off of my..." data-date="2024-04-01">thought</a>. It's a short note that I make
    about someone else's content online <a href="/tags/thoughts/" class="hashtag-tag" data-tag="thoughts" data-count=2 data-reading-time=3 data-reading-time-text="3 minutes">#thoughts</a>
