How to add row to JuliaDB table?

I know it’s supposed to be slow, but how do you add a row to a JuliaDB table?

// assume you start w/ t = table([1,2,3], [4,5,6], names=[:x, :y])

The closest docs I could find are:


edit: on a similar note, where does table persistence come into play?

3 Likes

If the table doesn’t have primary keys, you can do: push!(rows(t), @NT(x = 0, y = 0)). If there are primary keys, the idea would be to push! the row to a buffer and only add the buffer to the table and re-sort it when it’s needed but it’s not implemented yet.

1 Like

So do people just use SQL databases in the wild?

Primary keys seem kind of important?

So do people just use SQL databases in the wild?

I’m not sure what you are asking here. It should be reasonably easy to get a SQL database into a table, especially given that with IterableTables you can convert anything into anything, I don’t think you’ll need to manually push one row at a time.

Primary keys seem kind of important?

The API changed recently and some things take time to be implemented efficiently. The issue with primary keys (which are sorted) is that as soon as you push a row, you would need to sort again, so it has to be implemented in a lazy way so that it’s efficient to push many rows. For now, you would have to do it manually. You can always add rows with:

push!(rows(t), @NT(x = 0, y = 0))

But you may end up with a table that thinks some keys are sorted when instead they aren’t. To remedy that, the simple:

table(t, pkey = t.pkey, copy = false)

should sort things in place.

2 Likes

Sounds good. Looking forward to hearing more about JuliaDB in the future!

Is there a best place to listen for changes, examples and what not?

Good question, the docs are reasonably complete (especially given that it’s such a young project), otherwise you can either look at the source code, play a bit with the package or ask in the juliadb slack channel. A spreadsheet was shared in the data slack channel which should represent a “cheat sheet” for DataFrames, Query, DataFramesMeta and JuliaDB: maybe we could open a thread somewhere where people add whatever operation they think is general enough but they are unsure how to do.

1 Like