DEV Community

Discussion on: YEW Tutorial: 08 Dr. Ferris, I presume? Web Geography, injected with Rust! [P. I]

 
davidedelpapa profile image
Davide Del Papa • Edited

In reality this is a rollup.js error. It is searching for 'env'.
Did you install rollup-plugin-inject-env?

In case the command is:
npm i rollup-plugin-inject-env

At any rate, are you using odbc and odbc-crate compiled for wasm or as a serverside API? Since odbc wraps around a C driver I do not think it will compile to wasm. In case you succeed let me know 😃

Thread Thread
 
chasahodge profile image
Charles Hodge

Hi Davide, Thanks for all your help. This is looking pretty hopeless so far. What I'm looking to do is have a browser based app that accesses a local SQL Server running inside a Docker image on a Mac.I was hoping to access the db directly with out going through an API. I have one I created in React but was hoping for more efficiency by accessing the db directly.

Thread Thread
 
davidedelpapa profile image
Davide Del Papa

Well something can be done... Warning: it is a method prone to malicious attacks if exposed.
Here's the gist of it: you are going to access a local db with a local webpage, right? So there's less concern for protection (less in not none)
Anyways, odbc has got a SOAP interface:

docs.microsoft.com/en-us/previous-...

You might access it with the soap crate in Rust or with javascript (better solution).

It is a hacky trick, but it should work. But it takes a lot of effort. An API wrapper can be hardened for security, and you could interface it with JSON which is more universal and simple than SOAP...

Another way, which is useful if all the structure is in the same machine, is a wrapper to odbc that saves data to Redis, then to use the Redis server to exchange data with the webpage... Also lot of work, but you can prefetch and manipulate data before storing it to Redis. The advantage of having an API is that all the pieces are there, plus if tomorrow you want to interface other databases, local or remote, it's much easier to add. Also, I do not know your needs, but once you provide an interface, needs always arises to make some manipulation of data serverside before presenting it to the final user's interface...

Thread Thread
 
chasahodge profile image
Charles Hodge

Davide, thanks for your reply and all of your effort. I think since I already have an api built in React that connects to MS SQL db, I'll just continue to use it and get Rust to communicate with it and then send the data needed by the React frontend. Again, thanks for your efforts and knowledge.