Search Unity

Connecting to SQLClient from Unity *WebGL* Build

Discussion in 'Editor & General Support' started by ferretnt, Aug 28, 2019.

  1. ferretnt

    ferretnt

    Joined:
    Apr 10, 2012
    Posts:
    412
    Is this possible? I've spent an hour messing around copying DLLs, editing .rsp files, and reading out of date instructions and the opinions of people who want to create an intermediate web service rather than connecting to the DB.

    Unity 2018.4 .NET 4.6 (although could be 2.0 if required.)

    PS. I've already googled dozens of answers saying "don't do this, create a web service (I'm using a read-only account behind a VPN to try to visualize some data.) I've already read answers that tell you to randomly copy DLLs without saying exactly which DLLs or where too. I've already seen the video on Youtube that asks you to download a random DLL binary without verifying its authenticity. I've already tried downloading the Nuget Package Manager Asset and grabbing the SQLClient package.

    PPS. No, I don't want to use SQLLite. Yes Micro$oft is evil or something. I can't really begin by telling the client "so, first, just move all your databases to SQLLite..."

    I'd be really grateful for any help.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Are you trying to connect to SQL Server directly from your application? That creates a separate connection for every user and is huge security risk for SQL injection. And SQLite is a database on the mobile device for a single user, not a shared database. If a shared db, where is the database located, on AWS, Azure or other public host? Why not properly use a web service if this is a shared database?
     
  3. ferretnt

    ferretnt

    Joined:
    Apr 10, 2012
    Posts:
    412
    Yes. I know all of that. I even said so in my question and explained I’m using a read only user behind a VPN. Is there a way to do it, for a hacked together demo, on Friday, using an on premises MS SQL server. Assume my client wants to rapidly find out if this could be valuable not discuss architecture.

    Assume I’m aware of all the reasons why this isn’t the architecture going forward.

    The comment about sql lite was somewhat sarcastic, as that also exists as a useless non answer to this question.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Got it! However, if you are in a pinch, I might suggest a local Python server and just issue a GET request from the client, and connect to the db from Python. No need to implement a full web service. If I were in a hurry, this is the approach I would use, especially if it took me more than an hour to get it working natively from the client. Good luck on your project!
     
  5. ferretnt

    ferretnt

    Joined:
    Apr 10, 2012
    Posts:
    412
    Yeah, we currently have a variation on that which scrapes data from the database in Python and spits it out into Json files, so that as a python server would work. However, I was really hoping to keep everything within a Unity WebGL build, because I know everybody's computers are also on the VPN (trust me...) and we could just connect to the DB directly. Then I can just send a link to a hosted WebGL build and trust that it'll work when people click on it (modulo the fact that yes, in this world, people may be opening the link in Internet Explorer...)

    If I make a python server, I need to make sure my PC (or whatever I run it on) is connected to the network (at which point it's really another service.)

    It sounds like this isn't possible, based on many internet replies that suggest something different, and the fact that nobody seems to have managed.