Tiddlywiki Connection with Database

Hi,

I have some doubts regarding Tiddywiki.

  1. Does TiddlyWiki have a Database? How the tiddlers are stored inside Tiddlywiki?
  2. I want to access an External Database, which contains complex data. How can I access data from Tiddlywiki? Does it support a query mechanism? ( My DB queries contain main join operations as well, kind of complex query)

Thanks

At the moment TW does not use a database internally. The tiddlers are stored in an JS object-store for fast access.

Internally TW maintains some indices and caches to optimize performance. Eg for tags and filters.

I do not understand this one. Do you want to access an external database from within TiddlyWiki or do you want to access an external database with a 3rd party tool?

If you need an API to access TW data from a 3rd party tool, you will need to run a Node.js server, which loads the TW content into memory. The TW server will allow you to request JSON data.

The TW query language are “filter expressions” as used with the TW list-widget.

There have been questions. What are the doubts?

Yeah…in my case the database is an external one, example a DB running on my machine or cloud. Kind of private db. So I need to run a nodejs as a middleware to handle the calls. Am I right?

Yeah…what will be the memory limit for a single tiddler?
Is it unlimited?
How much data a tiddler can handle ?

If you want to access TW tiddlers from a 3rd party tool, that needs a server API to retrieve data, you will need a Node.js server – yes.

If you want to extract data from a database, where you have full control of the database there are 2 options to create a TW.

You can use “tm-http-request” to dynamically access data from a database using TW.

Or

You can extract static data from the database as a TW store object which is described at: How do TWs JSON Formats Look Like

In detail: How do TWs JSON Formats Look Like

You can use empty.html. Create a JSON file that contains a TW data-store as described above and concatenate those 2 files from a CLI – into a single file wiki.

The next time the TW will be opened, it will contain all the tiddlers from the store.

Hope that helps
-mario

Until your browser will crash. There are wikis out there, with 30k+ tiddlers.

But – It depends, what you want to achieve?

TiddlyWiki was designed to be a self-contained wiki. So it’s 1 HTML file, that contains all the data. So if you want to store text-based content it will be fine. If you want to store binary data it’s probably the wrong tool.

1 Like

In my case data is not constant, it will vary from the options I select and data can be updated by someone else. So data is constant at all.
For instance , if I did the same now. But there is a chance that someone might have changed the data. So I need the recent data rather than the older one.

I don’t have full control over the Database, I am just using it from a 3rd party.
Since the data is private can’t expose into API calls from tiddly.

Really appreciate the effort.
Currently I’m running a nodejs as a middleware to get the queries and retrieve the data.

I have some binary and hex coded data even more complex data rather than text. I will keep the data in db rather than storing in Tiddlywiki itself.

OK. So you use a Node.js server to retrieve data from the private database and create tiddlers with that data, so TW can understand it – right?

OK So TW shows some meta data about the binary data and provides some links to the “real” data if needed. – right?

1 Like

Yeah… exactly. The same you explained. I was checking whether tiddlywiki can handle some powerful queries inbuilt , then it would be amazing.

I retrive the data and converting to json , so that TW can easily understand. Data in the DB is pretty complex and it’s a graphDb.

Really appreciate for the wonderful insight.
Great explanation.

OK. I think that’s the right approach. The TW server has a possibility to “lazy-load” the tiddler body “content”. So the title and all fields are transferred to the browser. So you can efficiently filter your lists.

As soon as a tiddler is show, the content will be dynamically loaded from the TW server. This can speed up the initial load time significantly.

@linonetwo has a huge wiki that works that way. May be he can jump in here?

1 Like

I’m just online, so the link is 50M large / huge size of TiddlyWiki, performance remains good. Also a HugeWiki plugin for developers

Import it to NodeJS will show it works smoothly. But my own wiki’s UI might be slow due to some slow filters like Too slow! · Issue #1 · bimlas/tw5-kin-filter · GitHub . Not using them will make wiki fast.

1 Like

Thank you . I got more from those answers.

I used the filter and had some logic in the nodejs to reduce the loading issue. Till now UI works perfectly,

I am following this sqlite3 WebAssembly & JavaScript Documentation Index and I hope that by the time I learn the basics of the filter language, somebody who is much smarter than me will release an sqlite TiddlyWiki plugin which will provide an alternative to said filter language for managing tiddlers :smiley: Albeit I have no idea about the size inflation rate of a single file wiki that would bundle such a plugin.

1 Like

Yeah …I started to learn about Database using MySQL . Now I am using some powerful graphDB rather than normal RelationalDB.