Insert into Database from wiki page

LabKey Support Forum (Inactive)
Insert into Database from wiki page atul sharma  2017-06-19 06:56
Status: Closed
 
Dear Friend,

I want to insert data of my form into database which is connected to labkey.

(I have created a table in postgresql and now want to insert data into that table)

Is there any possibility to do it on wiki page?

If not with Query API.

Do I write a script to get the connection of database and then make an insert call?

I tried with LABKEY.Query.insertRows(config) it says forbidden.(I think it is read only)
Please help.

Regards
Atul
 
 
Jon (LabKey DevOps) responded:  2017-06-20 13:01
Hi Atul,

When you said you created a table in PostgreSQL, how did you do this?

Did you create its own schema as well? Did you create this table programmatically via a module or did you just directly create it via PostgreSQL?

The Javascript API is typically sufficient to insert data into tables within LabKey provided the table is accessible and can be viewed in the Schema Browser.

Regards,

Jon
 
atul sharma responded:  2017-06-21 15:53
Dear Jon,
I have just created the table directly via PostgreSQL under public Schema in Labkey Database.

In labkey under Schema Browser, Created New External Schema and marked editable check box.

Now This table should be Editable (insert/update). However, I have used Labkey.Query.insertRows() API method, It shows Forbidden alert box while executing.
 
Jon (LabKey DevOps) responded:  2017-06-21 16:11
Hi Atul,

That kind of setup isn't supported by the Schema Browser.

The LabKey database shouldn't be accessed as an external schema and external schemas should have their own datasource within the labkey.xml file.

Additionally, by creating it solely in PostgreSQL and not having an accompanying XML file, LabKey has no way of understanding how to design it within the Schema Browser or handle the table design. This is also why the Javascript API wouldn't work since it couldn't actually view that table properly.

We recommend that you create new tables that are not apart of the LabKey Core modules within your own custom module, where you can create your own schemas, tables, and queries.

- https://www.labkey.org/Documentation/wiki-page.view?name=sqlScripts

Regards,

Jon
 
atul sharma responded:  2017-06-23 04:35
Thanks Jon,

That was a mistake in Table creation. I did't make primary key.

Now it works fine.


Regards
Atul