Advanced Capstone 3.1 and 3.2

Hello! I wanted to ask, firstly, if this is the correct solution for loading the f1 database into the remote server for question 3.1… I am asking because there is no test to check at the end of the 3rd task.

hdbH : h : hopen 5099 f1data : get :../f1</span> <span class='"cm-variable"'>hdbH</span> (<span class='"cm-keyword"'>set</span>; <span class='"cm-symbol"'>f1data; f1data) hdbH `f1data

In parallel, I have more questions about 3.2. Firstly, the .Q.sha1 function does not work on my column string (I have checked that I work with string columns, and not with symbol columns). Even if I write .Q.sha1 “Hello world!” I get an error, therefore I use the .Q.fc function and retrieve the following table (screenshot attached - the api column is also in the table, even though not seen from the picture). Moreover, why were we advised to check the Advanced IPC Module before attempting this exercise, I do not believe this has anything to do with IPC (we are even told to save the variable locally - only for 3.3 we need to load the table into the remote server). In the other case, I am wrong in my thinking, but I have no idea where. The code for 3.2 is shown below 

show table : read0:../AdvancedCapstone.Data/users.txt</span> <span class='"cm-keyword"'>show</span> <span class='"cm-variable"'>myTable</span> <span class='"cm-keyword"'>:</span> ([<span class='"cm-variable"'>user</span> <span class='"cm-keyword"'>:</span> ()]; <span class='"cm-variable"'>password</span> <span class='"cm-keyword"'>:</span> (); <span class='"cm-variable"'>api</span> <span class='"cm-keyword"'>:</span> ()) <span class='"cm-variable"'>addToUsers</span> <span class='"cm-keyword"'>:</span> {[<span class='"cm-variable"'>newStr</span>] <span class='"cm-variable"'>words</span> <span class='"cm-keyword"'>:</span> <span class='"cm-string"'>"\t"</span> <span class='"cm-keyword"'>vs</span> <span class='"cm-variable"'>newStr</span>; <span class='"cm-keyword"'>if</span>[[<span class='"cm-variable"'>words</span>[<span class='"cm-number"'>0</span>] <span class='"cm-keyword"'>like</span> <span class='"cm-string"'>"user"</span>] <span class='"cm-keyword"'>=</span> <span class='"cm-number"'>0b</span>; <span class='"cm-symbol"'>myTable insert (</span><span class='"cm-keyword"'>$</span><span class='"cm-variable"'>words</span>[<span class='"cm-number"'>0</span>]; <span class='"cm-symbol"'>$words[1]; `$words[2])]; } addToUsers each table myTable : update string user, string password, string api from myTable .perm.users : update .Q.fc password from myTable show .perm.users

Hi, 

The start of section 3 is tested implicitly by returning the correct data later on. 

A couple of things to note from your first code snippet. You can remove the “h :” as your hdbH is the only assignment you need. 

I’m not sure what directly you are in, so I’m not sure if your line 

f1data : get `:../f1

is correct, but you don’t need to load the data and then use set as you are doing. A simpler way would be to use “\l f1” directly with your handle hdbH. 

For 3.2, if you wish to apply .Q.sha1 to a column of data you must use each ('). While 3.2 does not implement  IPC, the Advanced IPC exercises are useful for section 3 as a whole.

Hope this helps.

Laura

 

 

 

Dear Laura,

.perm.users : update .Q.sha1 each `password from myTable

Thank you for your response! However, for the line above, I get the mismatched types error. The same error applies if I remove the ` operator after the “each” keyword.

Hi, your syntax is incorrect.

You can use the word each or the single quotation mark ’ (not backtick ` as you have it)

Iterators - kdb+ and q documentation

Hope this helps,

Laura

Dear Laura,

I tried the combinations with the quotation mark and backtick, with and without each, and to no avail… is there any .q file or library I should load apart from dbmaint.q (which was loaded before running 1.1)?

Hi,

Can you send me a screenshot of what you mean? There is no combination required.

You can either use the word 

each

or the single quotation mark

'

between .Q.sha1 and password. The backtick is not correct here.

No extra libraries are required, these are in built functions within q. 

Hope this helps,

Laura

 

Sure! Here is the screenshot with the code and the error.

 

Dear Laura,

 

Thank you for your help! It works now… I commented out the first two lines at some point through all the checks - this is my mistake.

Thank you for all the help!