Is saving context a good way to save the whole database?

Content-Disposition: inlineHello,

I would like to persist all the tables created in a q session in a single file.

Is context set/get a good way to do this? Or ?

Regards,
Yuva

it’s certainly doable, tho it’s in some obscure part of one of thekx.com/q/d docs that I can’t seem to find right now. my guess issomething like:file set get.would do it, but i don’t have an installation handy at the moment to test on(also not sure whether that would capture every \d workspace in thesession, or only the main one–prolly the latter)On Fri, Jun 27, 2008 at 7:43 PM, Yuvaraj Athur Raghuvir<yuvaraj.a.r> wrote:> Hello,>> I would like to persist all the tables created in a q session in a single> file.>> Is context set/get a good way to do this? Or ?>> Regards,> Yuva>> >>– Aaron Daviesaaron.davies@gmail.com</yuvaraj.a.r>

yes, that the way to save it but it does it only for the root namespace.

to load it again:

. set get :file

you can wrap these into a set of functions and put them in q.q file to loaded at start-up.

felix

Ok. And taking Simon’s suggestion, I shall name the file to .qdata.

Now, if I want the store to be persistent - i.e, I want the server to be aware that when it is shutdown, it will serialize the context into a .qdata file, what should I do?

What I want is this:
a) launch q server on a certain port
b) have q server load context on launch
c) have durability property: ideally, the context should get flushed often so that context data is not lost.
d) on q server exist, flush the context to a disk file.

I would assume that this should be rather straight forward since I think that q can behave as a regular ACID database too. Is there standard code that is available at code.kx.com? Or, any pointers to documentation would help.

Thanks,
Yuva

using the .qdb form of database does what you want:start up q with -l logging enabled, give a database name (ggg here)simon@simon-macbook:~/q$ q ggg -l -p 5001KDB+ 2.5 2008.06.24 Copyright (C) 1993-2008 Kx Systems/ create a tableq)aa:(bb:til 5)/ force the log to be consolidated, then quitq)\lq)\/ restart, notice aa is theresimon@simon-macbook:~/q$ ls ggg*ggg.log ggg.qdbsimon@simon-macbook:~/q$ q ggg -l -p 5001KDB+ 2.5 2008.06.24 Copyright (C) 1993-2008 Kx Systems..q)aabb–01234q)the file ggg.qdb is the databaseggg.log is the log of changes to ggg.qdb - replayed on restart,consolidated by doingq)\lthe optional file ggg.q will be loaded and run at startup if provided2008/7/1 Yuvaraj Athur Raghuvir <yuvaraj.a.r>:> Ok. And taking Simon’s suggestion, I shall name the file to .qdata.>> Now, if I want the store to be persistent - i.e, I want the server to be> aware that when it is shutdown, it will serialize the context into a .qdata> file, what should I do?>> What I want is this:> a) launch q server on a certain port> b) have q server load context on launch> c) have durability property: ideally, the context should get flushed often> so that context data is not lost.> d) on q server exist, flush the context to a disk file.>> I would assume that this should be rather straight forward since I think> that q can behave as a regular ACID database too. Is there standard code> that is available at code.kx.com? Or, any pointers to documentation would> help.>> Thanks,> Yuva>>> On Mon, Jun 30, 2008 at 3:36 PM, Felix LUNGU <felix.lungu> wrote:>>>> yes, that the way to save it but it does it only for the root namespace.>> to load it again:>> . set get :file>> you can wrap these into a set of functions and put them in q.q file to>> loaded at start-up.>> felix>>>> On Sat, Jun 28, 2008 at 8:27 AM, Aaron Davies <aaron.davies>>> wrote:>>>>>> it’s certainly doable, tho it’s in some obscure part of one of the>>> kx.com/q/d docs that I can’t seem to find right now. my guess is>>> something like>>>>>> :file set get.>>>>>> would do it, but i don’t have an installation handy at the moment to test>>> on>>>>>> (also not sure whether that would capture every \d workspace in the>>> session, or only the main one–prolly the latter)>>>>>> On Fri, Jun 27, 2008 at 7:43 PM, Yuvaraj Athur Raghuvir>>> <yuvaraj.a.r> wrote:>>> > Hello,>>> >>>> > I would like to persist all the tables created in a q session in a>>> > single>>> > file.>>> >>>> > Is context set/get a good way to do this? Or ?>>> >>>> > Regards,>>> > Yuva>>> >>>> > >>>> >>>>>>>>>>>>> –>>> Aaron Davies>>> aaron.davies@gmail.com</yuvaraj.a.r></aaron.davies></felix.lungu></yuvaraj.a.r>