Rank: Newbie
Groups: Registered
Joined: 23/08/2016(UTC) Posts: 8 Location: Wymondham Was thanked: 16 time(s) in 5 post(s)
|
SQLite Interface Plugin Description:This plugin allows SMath Studio to interface the SQLite relational database engine. It has been developed for .NET 2.0 and SMath 0.98.5935 or newer Download & Installation:For SMath versions 0.98.5935 or newer the plugin can be conveniently downloaded and installed using the extension manager. Example and source code are now available in the SVN as well: https://smath.info/svn/p...ic/plugins/SQLitePlugin/To manually install the plugin, copy the folder (and all its contents) from the "SQLitePluging-[version].zip" archive into "%appdata%\SMath\extensions\plugins\". To run the example extract the contents of the "SQLiteExample-[version].zip" to any directory, make sure database and SMath sheet are located in the same directory and open the example sheet. Some older versions of SMath seem to require an additional "eval" in some of the statements, so two versions of the example sheet are provided. UsageUsage of the plugin is very simple: Code:SQLiteQuery("path", "query")
This will open the database file at the specified path (if not already open), execute the specified query and return the corresponding results. The results of the query will be returned as a matrix of corresponding size. A single result will still be returned as a 1x1 matrix. If no results are found the plugin will return Matrix(0,0). Empty (NULL) entries will be returned as the custom unit "'NULL" and are distinguishable from empty strings All used database files are automatically closed when SMath Studio is closed. ExampleLimitations, Known Problems and Remarks- Beta version, use with caution
- I have not yet checked whether different culture settings lead to conversion errors
Only SELECT statements have been tested so far Limited testing on write access queries seems promising, so far
Two DLL files need to be copied to the plugins folder, I intend to merge the assemblies in future
Assemblies merged, plugin is now a single dll Complete folder provided, Extension Manager upload in progress
Only 64 bit is currently supported, sorry. Working on 32 bit support Both 64 and 32 bit now supported (tested in 5935, 6081 and 6083 using WoW64)
Since it is not possible to use "=" within a SMath string this has to be considered when designing a query. "IS" and is usually a suitable replacement. "IS NOT" serves as a replacement for "!=" The boolean 'equal' (Ctrl + =) works very well (tested). Thanks Martin Kraska and Mike Kaganski for pointing out my error StoryI started using SMath Studio about 6 months ago, when I got sufficiently annoyed with the free version of MathCAD (no linterp? seriously?) and have since grown quite fond of it. I had a look around the Forum and the sheer amount of time, effort and dedication some of the people involved seem to invest is rather inspiring. Yesterday I found myself in need of a way to conveniently load a whole set of material properties and coefficients for curve fits by only specifying a part number - a task that a relational database seemed well suited for. I could not find an existing database interface and was quite interested in learning more about SMath plugin development, so I wrote the plugin myself (having previous experience with SQLite and C#). The performance seems pretty good, compared with the Excel I/O plugin. Comparing the corresponding examples the SQLite version executes on my machine initially in 0.7s, then in about 0.03s once the DB is opened. The Excel version takes 3.2s initially, 0.18s once the excel sheet is open. Since I enjoy the privilege to freely use SMath Studio, I gladly provide my plugin here as well, hoping you may find it to be useful. Please feel free to have a look and let me know what you think. I would very much welcome any problem reports, suggestions for improvements, requests for further explanations etc. Acknowledgements- Alex.M - I have taken the liberty here to adapt the example and database form Alex' Excel I/O plugin to demonstrate the SQLite interface within a context that might be familiar to some users. I had to change some property names since SQLite ignores case, b and B have become b1 and b2 etc.
- Davide Carpi - The XlsxImportExport plugin demonstrated to me how to properly return results in form of a Matrix. Also thanks for the useful feedback
- Martin Kraska - I found the "SMath Studio Handbuch" to be a great starting point and reference
- Martin Kraska & Kay Graubmann - The Maxima plugin source code provided some valuable insights into SMath plugin development
- Mike Kaganski - His quick testing, excellent feedback and good ideas have substancially accellerated and improved the development of this plugin
Changelog- 08/09/16 - Made plugin available to download via extension manager, uploaded source code and example to SVN, fixed relative path as suggested by Davide, changed loading of linked SQLite assemblies for x86 and x64 to allow installation from extension manager for SMath below 8069
- 31/08/16 - Removed single argument SQLiteQuery due to inconsistencies with partial recalculation. Null entries in database return custom unit 'NULL and are now distinguishable from empty strings, simplified code. Fixed and improved the example file, added typetest table to example database
- 29/08/16 - Updated SQLiteQuery to use path as handle, removed SQLiteOpen and SQLite close, added automatic closing of database connections at SMath exit, typecasting bugfixes, refactoring and minor improvements, repackaged for proper plugin installation
- 27/08/16 - Merged assemblies, now the plugin only consists of a single dll. Correct SQLite interop is automatically loaded, 64bit and 32bit are now supported. (Tested with SMath 5935, 6081 and 6083 )
- 26/08/16 - Added support for multiple simultaneous database connections, returning results consistently as matrix now
- 25/08/16 - First release
SQLite resources:Edited by moderator 06 November 2020 12:51:18(UTC)
| Reason: Not specified
|
6 users thanked ChrisBietz for this useful post.
|
on 26/08/2016(UTC), on 26/08/2016(UTC), on 26/08/2016(UTC), on 26/08/2016(UTC), on 29/08/2016(UTC), on 23/03/2020(UTC)
|