2
$\begingroup$

I want to store Mathematica results in an external rdbms, Postgres specifically.

The Mathematica documentation talks a lot (eg in 'Relational Database Quick Start') about extracting data from external databases but very little (to nothing?) that I can see about using external relational databases to store information.

It seems to me that to use something like

ExternalEvaluate[
 dbConnection,
"INSERT INTO tbl(col1, col2) VALUES "<> calculated_values_as_strings
]

is very rough and potentially unsafe.

With Mathematica V12's new RelationalDatabase and EntityStore objects there must be a nicer way to store data in an external RDBS. How is it done?

Is DatabaseLink the only solution?

$\endgroup$
3
  • 2
    $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$
    – LouisB
    Oct 20, 2021 at 9:42
  • 2
    $\begingroup$ Use SQLInsert to insert data into a table. If you have problems with SQLInsert we may be able to help you. Try to provide some minimal code that we can use to reproduce the problem. Also see the (minimal) example of batch inserting data here. To see a list of RDB commands, evaluate Needs["DatabaseLink`"]; Information["SQL*"]. $\endgroup$
    – LouisB
    Oct 20, 2021 at 10:05
  • $\begingroup$ So, just to be sure, regardless of the new objects 'RelationalDatabase' and 'EntityStore' the only option for submitting to an external database is through DatabaseLink and SQLInsert? $\endgroup$
    – TnTech
    Oct 21, 2021 at 2:09

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.