cancel
Showing results for 
Search instead for 
Did you mean: 

Advanced Capstone 3.1 and 3.2

anduhau
New Contributor II

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.

Spoiler
hdbH : h : hopen 5099
f1data : get `:../f1
hdbH (set; `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 

Spoiler
show table : read0`:../AdvancedCapstone.Data/users.txt
show myTable : ([user : ()]; password : (); api : ())

addToUsers : {[newStr] words : "\t" vs newStr;
    if[[words[0] like "user"] = 0b; `myTable insert (`$words[0]; `$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
1 ACCEPTED SOLUTION

Laura
Community Manager Community Manager
Community Manager

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

 

View solution in original post

7 REPLIES 7

Laura
Community Manager Community Manager
Community Manager

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

 

 

 

anduhau
New Contributor II

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.

Laura
Community Manager Community Manager
Community Manager

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

anduhau
New Contributor II

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)?

Laura
Community Manager Community Manager
Community Manager

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

 

anduhau
New Contributor II

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

 

anduhau
New Contributor II

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!