1

Im trying to install Ruby on Rails on my Windows 10 PC. for this is also want sqlite3 So I downloaded a precompiled binary for Windows, from https://www.sqlite.org/download.html The downloaded zip contains only a sqlite3.dll and sqlite3.def file. There is no sqlite3.exe file. So how can I make sqlite3 run on windows ?

    C:\sqlite3>dir
    Volume in drive C is Windows-SSD
    Volume Serial Number is FCBE-9AF1

    Directory of C:\sqlite3

   27-03-2022  09:09    <DIR>          .
   27-03-2022  09:09    <DIR>          ..
   27-03-2022  08:53             6,391 sqlite3.def
   27-03-2022  08:53         2,450,432 sqlite3.dll
                  2 File(s)      2,456,823 bytes
                  2 Dir(s)  185,646,313,472 bytes free

   C:\sqlite3>sqlite3 --vesion
   'sqlite3' is not recognized as an internal or external command,
operable program or batch file.

How can I use the def and dll on windows ? Or how can i get sqlite3 exe ?

1 Answers1

1

SQlite isn't a database engine running as a service, like MySQL. It's only a DLL, you link it to your program, you use the required primitives to open a database (a .db file) and only then you can send SQL to the engine.

SQlite is indeed way more evolved than a typed binary file, but it's not designed to be a shared database for multiple simultaneous clients. It's a way to save data to a "private" file and manipulate it very easily with SQL requests instead of seek, read and write system calls (plus a bunch of tricks to find data within the file). Obviously, this ease-of-use is at the cost of raw performances: you won't read data from SQlite at the same speed as a low-level file access. But you don't choose to use a local database for that, too.

Wisblade
  • 1,483
  • 4
  • 13
  • SQLite is in fact designed for multiple clients, but only on one machine. It can also be faster than reading induvial files in some situations. – Anon Coward Mar 27 '22 at 21:02
  • @AnonCoward I mean _simultaneous_ clients... Since `.db` file is often locked exclusively by applications, it greatly reduce this feature - in fact, I never seen a SQlite-based program that didn't locked the database. For speed, it's a no-match in favor of SQlite for seeking a particular record, thanks to SQL. Otherwise, you can't beat a raw file read, because in addition to the same read that the SQlite engine must perform, there is the SQL handling overhead. What you seen when SQlite was faster is probably an artifact caused by numerous cache hits. – Wisblade Mar 27 '22 at 21:15
  • SQLite only locks on writes. It's very common to have multiple readers operating at once. Benchmarking also shows there are plenty of cases where [SQLite is faster than filesystem access](https://www.sqlite.org/fasterthanfs.html). – Anon Coward Mar 27 '22 at 21:31
  • Never seen the case for multiple readers, so can't say further. For speed, the page you linked says why: no AV scan for SQlite, comparing file blobs (eq. to TAR archive, one node search only) vs. individual files (requires a node search per file), probably also prefetch by OS in favor of SQlite, and using basic `fread` and `fwrite` for comparison (instead of native calls or, better, `MapViewOfFile`/`mmap`). For reading, let's say, one million tuples from SQlite and from a structured binary file, I highly doubt that SQlite can match native direct I/O... That would be the only fair comparison. – Wisblade Mar 27 '22 at 22:27
  • Cool. But i dont know how to to use sqlite3 with just the dll . Thanks for looking into it. – Kim Kardashian Mar 28 '22 at 00:05
  • @KimKardashian It's "just" a library, check SQlite's online documentation for examples, functions, parameters, etc. to use it. Your immediate problem is now: _**How to import a C DLL within Ruby on Rails?"**_ And for this, RoR's documentation / forum should give you all the clues. Once the DLL is loaded and its functions imported in RoR, go for SQlite's doc. – Wisblade Mar 28 '22 at 08:15