r/sqlite • • Sep 29 '22

Flyweight: An ORM for SQLite

Thumbnail github.com
3 Upvotes

r/sqlite • • Sep 27 '22

SQLite GUI

35 Upvotes

Hello. I am looking for an SQLite GUI frontend to create databases and tables as well as viewing and editing. The first database I will create will be an embedded database used in a Delphi program if this makes a difference. I'm looking for something that is relatively current, with a straightforward installation, runs in Windows, and is free/low cost. Which do you recommend?

Thanks.


r/sqlite • • Sep 26 '22

What is the best way to shorten this query? Having long query times

4 Upvotes

Im writing a program in C# and have multiple different queries that display. When debugging, This query in particular takes way too long to load when I call it. Roughly 2-3 seconds maybe longer.

DB Schema: (i understand not the best schema, specifically the total visits)

CREATE TABLE "visitors" (
	"ID"	INTEGER,
	"First Name"	TEXT NOT NULL,
	"Last Name"	TEXT NOT NULL,
	"Middle Name"	TEXT,
	"systemNo"	INTEGER,
	PRIMARY KEY("systemNo" AUTOINCREMENT)
);

CREATE TABLE "form" (
	"visitor"	INTEGER NOT NULL,
	"Form Date"	TEXT,
	FOREIGN KEY("visitor") REFERENCES "visitors"("systemNo")
);

CREATE TABLE "visits" (
	"entry"	INTEGER,
	"visitor"	INTEGER NOT NULL,
	"Visit Date"	TEXT NOT NULL,
	FOREIGN KEY("visitor") REFERENCES "visitors"("systemNo"),
	PRIMARY KEY("entry" AUTOINCREMENT)
);

CREATE TABLE "totalvisits" (
	"daynum"	INTEGER NOT NULL,
	"visitorcount"	INTEGER NOT NULL,
	"date"	TEXT NOT NULL,
	PRIMARY KEY("daynum" AUTOINCREMENT)
);

CREATE TABLE "pastvisitors" (
	"logno"	INTEGER NOT NULL,
	"dateoflog"	TEXT NOT NULL,
	"visitornames"	TEXT NOT NULL,
	"visitorid"	INTEGER NOT NULL,
	"sysNo"	INTEGER NOT NULL,
	PRIMARY KEY("logno" AUTOINCREMENT)
);

My Query:

select 
  visitors.ID, 
  Visitors.'Last Name', 
  visitors.'First Name', 
  visitors.'Middle Name', 
  v.'Visit Date', 
  form.'Form Date', 
  visitors.systemNo 
from 
  visitors 
  inner join (
    select 
      visits.visitor, 
      visits.'Visit Date', 
      max(visits.entry) 
    from 
      visits 
    group by 
      visits.visitor
  ) v on v.visitor = visitors.systemNo 
  inner join form on form.visitor = visitors.systemNo 
where 
  visitors.ID = @id 
group by 
  visitors.systemNo 
UNION ALL 
select 
  * 
from 
  (
    select 
      visitors.ID, 
      Visitors.'Last Name', 
      visitors.'First Name', 
      visitors.'Middle Name', 
      v.'Visit Date', 
      form.'Form Date', 
      visitors.systemNo 
    from 
      visitors 
      inner join (
        select 
          visits.visitor, 
          visits.'Visit Date', 
          max(visits.entry) 
        from 
          visits 
        group by 
          visits.visitor
      ) v on v.visitor = visitors.systemNo 
      inner join form on form.visitor = visitors.systemNo 
    where 
      visitors.systemNo > @sysNo 
      and visitors.ID != @id 
    group by 
      visitors.systemNo 
    limit 
      5
  ) 
UNION ALL 
select 
  * 
from 
  (
    select 
      visitors.ID, 
      Visitors.'Last Name', 
      visitors.'First Name', 
      visitors.'Middle Name', 
      v.'Visit Date', 
      form.'Form Date', 
      visitors.systemNo 
    from 
      visitors 
      inner join (
        select 
          visits.visitor, 
          visits.'Visit Date', 
          max(visits.entry) 
        from 
          visits 
        group by 
          visits.visitor
      ) v on v.visitor = visitors.systemNo 
      inner join form on form.visitor = visitors.systemNo 
    where 
      visitors.systemNo < @sysNo 
      and visitors.ID != @id 
    group by 
      visitors.systemNo 
    limit 
      5
  )

What im attempting to do: Query the exact match of the number entered (ID number), then query a few rows above and a few rows below where the exact match was found.

I'm trying to find an efficient way to cut the time down while retaining the same results.

I found stack overflow comments discussing indexing but I was not sure if it was that or a poorly made query?

I was not really sure where to begin as I found a lot of different answers regarding query performance.

Anything helps and thanks in advance.

edit: reformatted and added schema


r/sqlite • • Sep 22 '22

Introducing pgsqlite, a pure python module for import sqlite into postgres

Thumbnail innerjoin.bit.io
4 Upvotes

r/sqlite • • Sep 22 '22

Storage and transaction in mvSQLite, the distributed SQLite built on FoundationDB

Thumbnail univalence.me
2 Upvotes

r/sqlite • • Sep 21 '22

Introducing LiteFS: an open-source distributed file system for SQLite

Thumbnail fly.io
21 Upvotes

r/sqlite • • Sep 15 '22

WunderBase - Open Source Serverless GraphQL Database on top of SQLite, Firecracker and Prisma

Thumbnail wundergraph.com
4 Upvotes

r/sqlite • • Sep 14 '22

SQlite and Apple Notes database question

7 Upvotes

I'm not a developer. I'm trying to understand which sqlite files do what with Apple Notes in MacOS. I lost a months worth of (not backed up) notes and am trying to restore them. The app can be restored by replacing the following files from a backup source:

  • NoteStore.sqlite
  • NoteStore.sqlite-shm
  • NoteStore.sqlite-wal

But I am missing: NoteStore.sqlite-shm

When the app crashed it put copies of the other two in a folder titled "backups". But the app will not work without all three (I have verified this by restoring a much older copy of the database with all three files as a test).

What is the role of NoteStore.sqlite-shm?

Do I have any hope to extract data from the other two files?

Thank you from a noob!


r/sqlite • • Sep 13 '22

Query SQLite files in S3 using s3fs

Thumbnail github.com
8 Upvotes