<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Knowledge Base (Posts about sqlite)</title><link>https://bgstack15.ddns.net/blog/</link><description></description><atom:link href="https://bgstack15.ddns.net/blog/categories/sqlite.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2025 &lt;a href="mailto:bgstack15@gmail.com"&gt;bgstack15&lt;/a&gt; 
&lt;a rel="license" href="https://www.gnu.org/licenses/gpl-3.0.html"&gt;
&lt;img alt="GNU General Public License v3.0"
style="border-width:0; margin-bottom:12px;"
src="https://bgstack15.ddns.net/.images/gplv3-127x51.png"&gt;&lt;/a&gt;</copyright><lastBuildDate>Fri, 23 May 2025 13:15:35 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Find xyz of village3 block in Luanti</title><link>https://bgstack15.ddns.net/blog/posts/2025/05/23/find-xyz-of-village3-block-in-luanti/</link><dc:creator>bgstack15</dc:creator><description>&lt;p&gt;If you want to find the exact coordinate of your &lt;a href="https://content.luanti.org/packages/Clyde/poi/"&gt;poi&lt;/a&gt; block which you buried in a wall or the ground somewhere, use this sqlite3 snippet.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;$ sqlite3 mapserver.sqlite
sqlite&amp;gt; &lt;span class="k"&gt;select&lt;/span&gt; o.* from objects o JOIN object_attributes oa ON o.uid &lt;span class="o"&gt;=&lt;/span&gt; oa.object_uid where oa.value like &lt;span class="s1"&gt;'%village3%'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
uid&lt;span class="p"&gt;|&lt;/span&gt;x&lt;span class="p"&gt;|&lt;/span&gt;y&lt;span class="p"&gt;|&lt;/span&gt;z&lt;span class="p"&gt;|&lt;/span&gt;posx&lt;span class="p"&gt;|&lt;/span&gt;posy&lt;span class="p"&gt;|&lt;/span&gt;posz&lt;span class="p"&gt;|&lt;/span&gt;type&lt;span class="p"&gt;|&lt;/span&gt;mtime
32467ab9-b5fb-4109-bf97-08e77b606b48&lt;span class="p"&gt;|&lt;/span&gt;-11&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="m"&gt;28&lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;-1345&lt;span class="p"&gt;|&lt;/span&gt;-1&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;|&lt;/span&gt;-85&lt;span class="p"&gt;|&lt;/span&gt;poi&lt;span class="p"&gt;|&lt;/span&gt;&lt;span class="m"&gt;1746707872&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;a href="https://bgstack15.ddns.net/blog/2025/scrot-luanti-village3-big.png"&gt;Screenshot of village3 poi block in-game&lt;br&gt;&lt;img alt="" src="https://bgstack15.ddns.net/blog/2025/scrot-luanti-village3.png"&gt;&lt;/a&gt;&lt;/p&gt;</description><category>game</category><category>luanti</category><category>sqlite</category><guid>https://bgstack15.ddns.net/blog/posts/2025/05/23/find-xyz-of-village3-block-in-luanti/</guid><pubDate>Fri, 23 May 2025 13:11:00 GMT</pubDate></item><item><title>Finding the best tokens to money ratio from mission items in Lego Universe</title><link>https://bgstack15.ddns.net/blog/posts/2025/02/20/finding-the-best-tokens-to-money-ratio-from-mission-items-in-lego-universe/</link><dc:creator>bgstack15</dc:creator><description>&lt;div&gt;&lt;p&gt;In the self-hostable &lt;a href="https://bgstack15.ddns.net/blog/outbound/https:/github.com/DarkflameUniverse/DarkflameServer"&gt;Darkflame Lego Universe&lt;/a&gt; game server, you can earn 2 types of currency: money, and faction tokens. In the late game, you accumulate these in spades, but only money is still the most useful. So a lot of advanced players are interested in determining the most efficient way to convert faction tokens into money.&lt;/p&gt;
&lt;p&gt;The way to do this scientifically is within the database. All the mission objects are stored in the CDServer.sqlite file, so we can use sqlite3 for this.&lt;/p&gt;
&lt;p&gt;I have a whole methodology of what I did, in heading Narrative below. It's very lengthy, and really just my scratch pad combined with the steps I took to become familiar with the database.&lt;/p&gt;
&lt;h2&gt;tl;dr&lt;/h2&gt;
&lt;p&gt;All the experienced Lego Universe players are right: Castle Model Pack 3. You can buy this for 10 tokens at &lt;a href="https://bgstack15.ddns.net/blog/outbound/https:/legouniverse.fandom.com/wiki/Honor_Accolade"&gt;Honor Accolade&lt;/a&gt; in Nexus Tower, and sell the items from it for 798 money, which makes the token:money ratio 1:79.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://bgstack15.ddns.net/blog/2025/tokens-to-money.png"&gt;Fun picture showing ratio of money to tokens at 79:1&lt;br&gt;&lt;img alt="" src="https://bgstack15.ddns.net/blog/2025/tokens-to-money.png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;Sql query&lt;/h2&gt;
&lt;p&gt;You need at least &lt;a href="https://bgstack15.ddns.net/blog/outbound/https:/sqlite.org/releaselog/3_39_3.html"&gt;sqlite 3.39&lt;/a&gt; for the FULL JOIN operation. My narrative explains the same query without it, but you're not going to like it.&lt;/p&gt;
&lt;p&gt;Technically this query is still incomplete because it shows some of the "small number of random options for rewards" but they also aren't available at Honor Accolade.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;SELECT i.mid, IFNULL(i.tokens,0)+IFNULL(p.tokens,0) tokens, IFNULL(i.money,0)+IFNULL(p.money,0) money, ((IFNULL(i.money,0)+IFNULL(p.money,0))/10)/(IFNULL(i.tokens,0)+IFNULL(p.tokens,0)) moneypertoken, i.oid, i.name, p.o2count, p.o2id, p.o2names
FROM (
    SELECT m.id mid, SUM(IFNULL(ic.commendationCost,0)) AS tokens, SUM(IFNULL(ic.baseValue,0)) money, o.id oid, o.name name, NULL, NULL, NULL
    FROM Objects o
    JOIN ComponentsRegistry cr ON cr.id = o.id
    JOIN ItemComponent ic ON ic.id = cr.component_id
    JOIN Missions m ON o.id IN (m.reward_item1, m.reward_item2, m.reward_item3, m.reward_item4)
    WHERE cr.component_type IN (11)
    --AND m.id IN(427,14,17,82,633)
    GROUP BY o.name
) i --items
FULL JOIN (
    SELECT mid, SUM(IFNULL(tokens,0))+SUM(IFNULL(tokens2,0)) tokens, SUM(IFNULL(baseValue,0))+SUM(IFNULL(baseValue2,0)) money, oid, SUBSTR(MAX(oname),1,300) name, o2namecount o2count, SUBSTR(GROUP_CONCAT(o2id),1,300) o2id, SUBSTR(GROUP_CONCAT(o2name),1,300) o2names
    FROM (
        SELECT m.id mid, cr.component_id as crid, ic.baseValue, ic.commendationCost AS tokens, o.id oid, o.name oname, pc.LootMatrixIndex, SUM(ic2.baseValue) baseValue2, SUM(ic2.commendationCost) as tokens2, SUBSTR(GROUP_CONCAT(o2.id),1,300) o2id, SUBSTR(GROUP_CONCAT(o2.name),1,300) o2name, COUNT(o2.name) o2namecount, GROUP_CONCAT(ic2.baseValue) o2_baseValues
        FROM Objects o
        FULL JOIN ComponentsRegistry cr ON cr.id = o.id
        FULL JOIN ItemComponent ic ON ic.id = cr.component_id
        FULL JOIN PackageComponent pc on pc.id = cr.component_id
        FULL JOIN LootMatrix lm ON lm.LootMatrixIndex = pc.LootMatrixIndex
        FULL JOIN LootTable lt ON lt.LootTableIndex = lm.LootTableIndex
        FULL JOIN Objects o2 ON lt.itemid = o2.id
        FULL JOIN ComponentsRegistry cr2 ON cr2.id = o2.id
        FULL JOIN ItemComponent ic2 ON ic2.id = cr2.component_id
        FULL JOIN Missions m ON o.id IN (m.reward_item1, m.reward_item2, m.reward_item3, m.reward_item4)
        WHERE cr.component_type = 53
        AND cr2.component_type = 11
        --AND m.id IN (427,14,17,82,633,1254)
        AND lm.percent &amp;gt; 0.98 AND lm.minToDrop &amp;gt;=1
        AND o.id &amp;gt; -1
        GROUP BY o.id
    )
    GROUP BY oid
) p --packages
ON i.oid = p.oid
ORDER BY moneypertoken DESC
;
&lt;/pre&gt;&lt;/div&gt;

&lt;h3&gt;Inferior sql query&lt;/h3&gt;
&lt;p&gt;The query without full joins and is slightly more flawed, is this one. You can run this on CentOS 7 sqlite3 (less than 3.39).&lt;/p&gt;
&lt;p&gt;&lt;a href="https://bgstack15.ddns.net/blog/posts/2025/02/20/finding-the-best-tokens-to-money-ratio-from-mission-items-in-lego-universe/"&gt;Read more…&lt;/a&gt; (22 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>game</category><category>lego</category><category>narrative</category><category>sqlite</category><guid>https://bgstack15.ddns.net/blog/posts/2025/02/20/finding-the-best-tokens-to-money-ratio-from-mission-items-in-lego-universe/</guid><pubDate>Thu, 20 Feb 2025 14:29:00 GMT</pubDate></item><item><title>Jellyfin Chromecast selection never appears</title><link>https://bgstack15.ddns.net/blog/posts/2022/09/22/jellyfin-chromecast-selection-never-appears/</link><dc:creator>bgstack15</dc:creator><description>&lt;p&gt;I had a problem with my production Jellyfin server a few days ago.&lt;/p&gt;
&lt;p&gt;User "jellyfin" was unable to pull up the menu of available Chromecast targets, so Chromecast was entirely unavailable. Also, new logins for the user would not always go through. The server logs showed:&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;2022-09-19 09:09:10.415 +00:00&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;INF&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;43&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Emby&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Implementations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;HttpServer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nl"&gt;WebSocketManager&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;WS&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="ss"&gt;"258.1.15.15"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;request&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;2022-09-19 09:09:10.526 +00:00&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;ERR&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;[&lt;/span&gt;&lt;span class="n"&gt;13&lt;/span&gt;&lt;span class="o"&gt;]&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Microsoft&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;EntityFrameworkCore&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nl"&gt;Query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;An&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;exception&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;occurred&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;while&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;iterating&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;over&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;results&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;query&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;type&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'"Jellyfin.Server.Implementations.JellyfinDb"'&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="ss"&gt;"&lt;/span&gt;
&lt;span class="ss"&gt;"&lt;/span&gt;&lt;span class="err"&gt;"&lt;/span&gt;&lt;span class="k"&gt;System&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nl"&gt;InvalidOperationException&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;The&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;data&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;is&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;at&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;ordinal&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mf"&gt;5.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;This&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;method&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;can&lt;/span&gt;&lt;span class="err"&gt;'&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;be&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;called&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;on&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;NULL&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;values&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;Check&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;using&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;IsDBNull&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="k"&gt;before&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;calling&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="w"&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;A search of the Internet and more specifically github jellyfin showed a promising &lt;a href="https://github.com/jellyfin/jellyfin-web/issues/2507#issuecomment-894690573"&gt;suggestion&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://github.com/sbstp"&gt;sbstp&lt;/a&gt; commented on Aug 7, 2021 
@&lt;a href="https://github.com/sweisgerber"&gt;sweisgerber&lt;/a&gt; I actually found a better fix, this issue came back for me. The fix was to go into jellyfin.db with sqlite3 (command line) or sqlitebrowser (gui) and delete the rows of &lt;code&gt;CustomItemDisplayPreferences&lt;/code&gt; where value is null. Make sure to backup the db before doing that just in case.&lt;/p&gt;
&lt;div class="code"&gt;&lt;pre class="code literal-block"&gt;DELETE FROM CustomItemDisplayPreferences WHERE Value IS NULL;
&lt;/pre&gt;&lt;/div&gt;

&lt;/blockquote&gt;
&lt;p&gt;Somehow the settings in the database table got corrupted. This is probably a failure of the application logic and not something done by a user. But it's something I can live with! Thankfully there are smarter people on the Internet who experienced this before I did.&lt;/p&gt;</description><category>jellyfin</category><category>sqlite</category><category>troubleshooting</category><guid>https://bgstack15.ddns.net/blog/posts/2022/09/22/jellyfin-chromecast-selection-never-appears/</guid><pubDate>Thu, 22 Sep 2022 13:22:38 GMT</pubDate></item><item><title>Read Chrome and Firefox history from command line</title><link>https://bgstack15.ddns.net/blog/posts/2019/04/07/read-chrome-history-from-command-line/</link><dc:creator>bgstack15</dc:creator><description>&lt;h3&gt;Chrome&lt;/h3&gt;
&lt;p&gt;Shamelessly ripped from &lt;a href="https://www.quora.com/How-do-I-access-Chromes-history-saved-browsing-history-file-as-a-readable-format-without-using-third-party-applications-or-extensions"&gt;How do I access Chrome's history (saved browsing
history) file as a readable format without using third-party applications or
extensions? - Quora&lt;/a&gt; You will need a sqlite3 binary, probably from the
package &lt;strong&gt;sqlite&lt;/strong&gt; , to read the Chrome history file. Chrome history in Linux
is normally stored as file &lt;strong&gt;~/.config/google-chrome/Default/History&lt;/strong&gt;.&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;sqlite3 ~/.config/google-chrome/Default/History "select datetime(last_visit_time/1000000-11644473600,'unixepoch'),url from  urls order by last_visit_time asc" &amp;gt; output.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;h3&gt;Firefox, Palemoon, Waterfox&lt;/h3&gt;
&lt;p&gt;This one's in UTC. Find the relevant history sqlite file. For palemoon, it is
similar to:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;code&gt;~/".moonchild productions/pale moon/1234abdf.default/places.sqlite"


sqlite3 ~/".moonchild productions/pale moon/1234abdf.default/places.sqlite" "select datetime(h.visit_date/1000000,'unixepoch'),p.url from moz_historyvisits as h, moz_places as p where p.id == h.place_id order by h.visit_date asc;"
&lt;/code&gt;&lt;/pre&gt;</description><category>browsers</category><category>chrome</category><category>history</category><category>oneliner</category><category>sqlite</category><guid>https://bgstack15.ddns.net/blog/posts/2019/04/07/read-chrome-history-from-command-line/</guid><pubDate>Sun, 07 Apr 2019 12:36:38 GMT</pubDate></item></channel></rss>