Using MySQL databases in Mathematica

后端 未结 2 747
挽巷
挽巷 2021-02-05 20:29

I\'ve seen it\'s possible to make a connection between Mathematica and MySQL databases using Input Needs[\"DatabaseLink\"] and conn = OpenSQLConnection[JDBC[\

相关标签:
2条回答
  • 2021-02-05 20:53

    I recently used databases to speed up a Manipulate[] block.

    Without the database, essential data from a 150 MB ASCII file were required in memory for access. As a result, the Manipulate[] block slowed down. It's possible that PackedArray[] would have helped. I didn't investigate this.

    With the database, the speed of access of individual datasets is slightly slower than a Select[] block, but the memory footprint is down by a factor of nearly 10.

    I'd say go for it.

    0 讨论(0)
  • 2021-02-05 21:16

    I have not used DatabaseLink` with MySQL, but I have used it extensively with Oracle, SQL Server and HSQLDB. Most of my DatabaseLink` usage has been on Mathematica versions 6 through 8, on Windows. I have used it for both reading and writing, sometimes with very large data sets. My experience has been that the facility works as expected. I did not run into any unusual situations involving performance or memory. I would expect you to find SQL access in Mathematica to be comparable to what you have experienced in other languages. In particular, it performs very much like using Java -- presumably because Mathematica uses Java internally to do all of the heavy lifting.

    I will mention that the "obvious" way to execute queries in Mathematica, SQLExecute, will read the entire result set into memory. If you want work with large result sets without running out of memory, take a look at the result set functions SQLResultSetOpen et al.

    For a very basic example of SQL use in Mathematica (using HSQLDB), see my response to The best way to construct a function with memory.

    0 讨论(0)
提交回复
热议问题