Django Python Connect To MS SQL Server Display Records

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello friends welcome to my channel this is Sharon in this video tutorial I will explain in jungle web application how to connect the SQL Server database and display recalls on a view page the employ LD impedance email and salvage we are getting these recalls from the SQL Server management studio that's it I have shown in this video how to connect the SQL Server database and fetch recalls on the browser in general web tutorials if you are a first-time visitor to my channel please subscribe to get the latest updates before creating a new jungle bail application first we'll check back editors I just going to my SQL Server management studio the table name is a tree empirical switch contains four columns EMP ID epidemic a melon stop this EMP ID is auto generate column my aim is I want to connect this database from Django web application and through this data table and display on the index view page so let's start the coding part before creating in his jungle application first we'll create a new folder in local disk detail like in tomorrow's and selecting new and uncertain folder and the folder name is connect SQL Server this birth data is one project folder named X boxes folder the folder is empty right now now let's create a new chunk of lab application in this folder I'm using Visual Studio code to create a jungle web application first I add the folder which they have created in the local disk D trial open file after that open folder and the folder name is a character scopes our display data with select folder button and here the project folder is added successfully to the Explorer panel a grand said we got the welcome page let's close this welcome page you know let's add a new jungle web application in this folder look click view and sub terminal and here we got our terminal which is a command College you notice the path is that the folder name in the desired now let's create the jungle by reputation Django - admin stop project and the product name is SQL server connect it's my application name click enter and the project is created successfully into this fall that may explain this application if you notice in this application contents on subfolder the same project name and below that we got one manager nearby which is a Python file let me expand the subfolder also and in the sub folder contains some default item files like settings the provider Alex all these files and folders has been created automatically when I create this project s code server connect now after creating a project now the next step is now the next step is we'll creative on campus folder to add our HTML figures so I'm selecting the application name right click the mouse click the mouse with new folder and the folder name is a complex enter and here we got our tablets now in the standards folder I'm adding my HTML pages I click the mouse click new file the file name is at index dot HTML and there and here we got her in mid-august era now let's add some HTML doctype doctrine because in the HTML tag and said the HTML I'm adding the header section and the headers extra I'm adding the title enact a still slower song jangle after the header section and add in the body tag and said the body tats I'm adding the sentence no in the senate adds I'm adding the hitch one headers how to cannot SQL Server database and and this pair together H to hide relax Django web can go grab tutorials after the headings I'm adding a hostage alive now after the horizontal line I want to display this EMP recalled data here in this table fuel element so I'm adding on table with a border is equals to one the our table headers are not English table the first one is a employee ID employee and rename a name TV female an extra is a salary after adding the headers the next TR and this TR I'm adding the chili which is a table take up that table data we are getting from the database table so to get the ligaments first we required two connection strains so for that let's go so this fight fast sale on now let's add a moral stage in this sub folder if I click the sub folder click new fun moral stuff fever enter and here we got all moral stop here at this now in the smallest freshmen can say class with some proper dates so before the first we need to import the class the necessary class from Django dot DB input morals class after that let's define a class SQL server connect 0 and n is my class named morons dot moral column on this class I'm defining the properties so what properties the check in our database table empirical table contains four columns the EMP ID column is the auto generate column so I don't require for that property so I require these three columns EMP man let's copy this one here to name moral starch caffeine max underscore land is equals 200 let's copy this one this one is email the second property name and the third one is a salary salary Zico strove to check my database table the EMP table I'm also certain integer value so let's add the data type integer field and deserve that's it after adding the necessary properties in this class lecture is filed now we require the views parents to call this model again right click the sub folder click the new phone user py use the fever enter and here we got all views the fever ish now in this views of tea wine first we'll add input the classes from Django drop-shot cards import from the shortcuts I am importing the class is the vendor class this underpass is usual to remember our external pages on the browser after that they required the class them from this moral stage so copy this class Liam switch back to the views page from this morals page is inside the SQL server cannot folder so SQL saga connect dots models input from the smalls I'm adding my class name control the let's copy then how do we spawn and cashier now after that the next happens when we want to connect the SQL server we need to install the package so come to the command prompt pip install python py ODBC enter we have the requirement already satisfied but here I forgot to add by the application so let's control see we need to add first of all the application name with the project then let's install the Python ODBC and here the requirement already satisfied after that let's import import Python py or EB C then let's define the function in the function connect civil NN SPL is my function name in this function a request request : first we require our connection string grievers so for that I'm preparing a variable 0 and n is equals to null of a de dy body BC that connect matter now in this connect matter between single corals I'm adding my the eschol sour driver driver is equals to within curly brackets as la escalera as well as well son semicolon and the next one now between his single calls and adding my server server is equals to in the server I'm adding my SQL Server name which is the user - PC SQL Express let's add the fun user - PC backward slash SQL Express semicolon again single codes now the third property I'm earning the database database is sequels to our databases and then switch back to our SQL Server the database is a cm the Daedalus is of SIA I have created this EMF it cost in this CM database so let's add cm cm semicolon again Kaluga as single quotes trusted trusted underscore collection is equals to s single that's it they have added our SQL server connection strength properties and then after that the next step of the fountain the SQL server is successful now we have to add our SQL statement to fetch the data so I'm using cursor dot R is equals person here is equals to cursor object conduct have some method this castle method is usual when we want to execute the the acid sequence of structures we use concern method in general applications let's after that let's execute the statement has a dog execute method within single quotes select star on the table name our table name is EMP because so let's add a name a because prophet as one and first year some ones are recorded once the statement is executed I want to fetch all the records so again cancer duck search all method I'm fetching all the records from this PNP records table then then the last step we need to render our estimate tablets so return a random one Ganga request the second parameter is and the second parameter between single quotes I'm adding my a template name which is index dot HTML then the last tab within curly brackets here and using the a dictionary to further a cause to disclose the records in this index RS channel so first I'm adding my class name which is a team between simcoe's I'm adding key Colin the requests were getting from this fetch all metal so let's declare the variable here result is equals to result is an object result is equals to cause a duck fetch all so I'm copying this value result that's it let's say this file save all so once we return the code in this view space now we need to configure our URLs also so open your own stuff diva in the URL stop T Y and notice that your path is the advantage is a default one but our car now which is a home page views dot the Indians original page I want to render this HTML page with the help of this functional so I'm talking dysfunctional and I'm adding here and also we need to import the gooseberry also from got input views that's it let's save this file sale on and now the most important settings settings part open settings of p1 first we need to install allow the application name in the settings of P wine we notice our application definition which contains some installed apps so here we need to add our application name which is a struggle connect after adding s Kosovo connect again come to the bottom we need to configure our camp let's alter our campers is we need to configure our templates also so here I'm joining our camp runs with a base Dr Dre so that one I'm adding in this data section OS Jakarta joined method base directory comma between singing so I'm adding the campus folder this folder mem I'm adding that's it let's hear this file now the final stuff they need to bind the data and the Indian status Gianna in this table between curly brackets person this person - and fetching the recalls using Farlow five data disc a in there it is living morals the Gators are getting from this SQL Server Khan the class man let's add that one here class name and after TR between percentages and frozen father will enter then in the theories between double curly brackets in the expression I am adding the data display god I'm adding the IDE here the ideal which is NTID public at one chilly there are displayed dot second column name is at the MP name TV again the expression between double curly brackets did that displayed got email for double color balance and to be the last expression for the salary get a display dot Saturday that's it that's it have done the complete coding part now let's save this file now let's on the solve our Python vanish drop t1 runs saga enter and it's the notice of the rerun the Saba you don't have any issues now application but they have fifteen and applied migrations so let's add on the migrate also control seated at the Sawa control C elfs migrate that drifting migrations to a project now that's on the saga and now if you notice don't have any issues all we don't have any warnings here and we know that we got our brats our link control + mouse click and here we got the fun enough of notice the Hydra Dax a brother we got the chaebols unclarity infinity melon salad yeah the female and South why it's not showing the bowl or because it's table had sth sulfa that he hates th and this one also to have stable headers that so this file control as then i'm reloading the browser so now the table headers are showing in bold letters employee name email the employ LD impedance email and salvage we are cutting these recalls from the SQL Server management studio that's it I have shown in this video how to connect the SQL Server database and fresh recalls on the browser in Django web tutorials
Info
Channel: Haritha Computers & Technology
Views: 32,748
Rating: undefined out of 5
Keywords: Python Django, SQL Server, pyodbc, connect to SQL Server, database management, web development, Python, Connect to SQL Server djanog Python, how to use pyodbc django python, connect sql server django, django web application sql server, sql server, django, Python SQL SERVER using PyODBC, pyodbc python django, How To Connect To SQL Server In Python, How to Connect to SQL Server with Python python connect to sql server, Connect to SQL Server with Python
Id: QcCISY-OOeU
Channel Id: undefined
Length: 21min 54sec (1314 seconds)
Published: Sat May 02 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.