3

I'm looking to build an open source website project that will require a small database backend. I'm leaning towards using SQLite since the website will be simple, low traffic, and the users of the website will only be reading. Only the site admin will be updating.

I wonder though, sharing a SQLite file on GitHub, is that the best way? It's kind of hard to easily view the data. Is there a better data store solution for open source projects? Is it best to just include the data in a second format, like CSV, alongside the database?

7
  • 2
    How many times per day will the database be read?
    – Nicolas Raoul
    Oct 29, 2018 at 7:44
  • 2
    What web server software are you planning to use?
    – Nicolas Raoul
    Oct 29, 2018 at 7:45
  • 1
    Are you saying you want to distribute the stored data along with your source code? Why? How does that make sense if the data is changing (you said admins will be changing the data in the database)? Oct 29, 2018 at 7:56
  • 1
    What does small, smoke, and low-traffic mean to you? Get more specific if you want helpful Answers. Oct 29, 2018 at 7:57
  • @NicolasRaoul I would estimate maybe 50 reads a day. At this time, running on IIS.
    – dangowans
    Oct 29, 2018 at 12:41

2 Answers 2

1

Several open source webapps (namely Alfresco and Liferay) distribute a small amount of data with the webapp, to make it easy to get started with. A beginner can just run the start script, and the webapp is up and running already with sample data.

Here is how they do:

  1. Write a standard SQL script that creates the data.
  2. Write some code that creates an empty HyperSQL and loads the SQL from step 1 into it.
  3. Commit both the SQL script and the code into GitHub.
  4. When a webmaster downloads the webapp and runs it, the first time it will create the database. The webmaster can then add more data.

Please note that the HyperSQL database has a memory cache, so each read does not mean a disk read access. Each write means a disk write access, though.

2
  • I like this, keep things as readable as possible, than compile them on first run. I'll dig more into this idea.
    – dangowans
    Nov 1, 2018 at 15:39
  • I opted for SQLite. Thanks for the advice.
    – dangowans
    Nov 8, 2018 at 20:57
0

Your question is not clear, but it seems your goal is to distribute a relatively fresh copy of your database’s data alongside the source code of your app that accesses that database. But you do not explain your motivation or goal. I imagine you either want machines to read that data, or you want people to read that data.

Either way, consider distributing the data separately from the source code. Combining them is unusual and seems confusing to me.

Machine-readable

If your goal is convenience in establishing an instance of the database for the programmer using your source code to build and deploy for themselves, then you should include the database’s data files.

You could do this win SQLite. But beware that SQLite is indeed quite “lite”, meant more as a slightly better alternative to writing files, it is not meant to be a serious database. You have not stated the size and shape of your data, so I cannot advise if SQLite fits your needs or not.

A more serious database you might consider is the H2 Database Engine. It is written in Java, and so requires a JVM. H2 stores data to a single file that your could easily copy. H2 can run embedded within an app, or can be run separately as a database server.

Human-readable

If your goal is simply to let people peruse a recent copy of the data, then you need to export the data from the database to a human-readable text format.

If the goal is simply perusing, then write out web pages using basic HTML using the table tag. And perhaps a bit of CSS. Use the programming language of your app to generate these text files.

If you want the user to make use of the data such as opening in a spreadsheet, then use a common format such as Tab-delimited (TSV) or Comma-separated Values (CSV). You might want to use a library to assist in the writing of such files, like Apache Commons CSV in Java (which also writes TSV).

You will likely want to write out one file for each table in your database. Beware of memory limits in web browsers and spreadsheet apps; you may need to break a very large table into multiple files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.