Then require the following packages from tedious at the top like this:Ĭonst connectToServer = () => ipcMain. You can name it anything you want, I call it sqlservice.js: Start by creating a new sub-folder in the src folder of your electron app and adding a new javascript file under it. We are now ready to write our service or module to query SQL server database The documentation is not very intuitive but it's not bad either. I chose this package because it's been actively maintained and supported. TediousJS is a Node package that provides an implementation of the TDS protocol, which is used to interact with instances of Microsoft's SQL Server. Then assign the newly created login to your database I am using Windows Authentication and you can follow either this article or Microsoft's article to create a new login. You will need to configure either Windows or SQL Server Authentication to be able to connect successfully to your server. NOTE: Setting up SQL Server is out of scope for this article but you can download the express edition HERE and install it.Īlso a note on SQL Server Authentication. You can use any database you like to follow along but I have got AdventureWorks setup on my installation. Any version would work but I have got SQL Server 2019 Express Edition on my machine. You should see a barebone Electron, React, TypeScript App like this:įor this post, we will need a SQL Server installation. Of course, I have bumped up all the dependencies to the latest versions (fairly latest □) If anyone interested to know more details on how and why I have configured things in a certain way, then take a look at ALEX DEVERO BLOG's Part 2 of 5, where He explains the tech stack and all the dependencies in detail. Installation & Configuration of Prerequisites:Īs setting up Electron, React and TypeScript with all the bells & whistles can take quite a bit of time and a daunting task for a beginner, to make things easy I have already set up a sample GIT repo so you all can easily clone and follow along by just doing npm install and npm start. (NOTE: If you already have a SQL Server Installation with any Database and also a working Electron/React App then skip over to Installing TediousJS section) Let's get started first by setting up the prerequisites, and then installing and configuring project dependencies. So in this post, I am gonna show you how we can use Tedious, to connect and query MS SQL Server database from our Electron app's renderer process, using React and Typescript for front-end. So I decided to write a sample app that does exactly that. In this video, we will learn How to Connect to SQL Server database using Electron JS.In order to access SQL Server database using Electron JS we need to firs. I wanted something that shows how to integrate Microsoft SQL Server database, NodeJS, ElectronJS, and ReactJS, end-to-end. Almost all the good examples that I found were node apps using the NoSQL database as a back-end, like MongoDB. Recently, I was looking for some examples of database applications written in Electron and React, for one of my project I am working on these days.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |