Node.js + MySQL CRUD - GET,POST,PUT and DELETE

Поделиться
HTML-код
  • Опубликовано: 14 окт 2024
  • MySQL CRUD Operations in Node.js application.
    Updated video is here : bit.ly/3MwUcwS
    In this tutorial, we'll discuss how to implement crud operation insert update delete and view all in node.js with MySQL database.
    Content Discussed :
    How to Connect MySQL DB from Node.js
    Execute MySQL Query From Node.js
    Use of MySQL Store Procedure in Node.js.
    📂 GitHub Repository
    ► goo.gl/3JKBNM
    💖 Buy me a Coffee
    ➤ bit.ly/3L36ut4 (PayPal)
    ➤ bit.ly/3VF0iPT (Razorpay)
    🌀 Related Videos
    goo.gl/T9Nb8r : Angular CRUD with Web API
    goo.gl/wp17ta : Angular User Registration With Web API
    goo.gl/4gDFfC : Angular Login Logout With Web API
    goo.gl/ySUFf8 : Similar Mvc Tutorials
    🔗 Find me in
    Udemy : bit.ly/3RtyQSB
    Facebook : / codaffection
    GitHub : github.com/cod...
    Discord : / discord
    Twitter : / codaffection
    #NodeJS #MySql #CodAffection

Комментарии • 321

  • @CodAffection
    @CodAffection  6 лет назад +9

    goo.gl/RFY5C2 : Subscribe to CodAffection
    goo.gl/bPcyXW : Buy me a Coffee

    • @satyamshukla4777
      @satyamshukla4777 5 лет назад

      How can using MySQL and MS-SQL on the same machine

    • @rehthro
      @rehthro 3 года назад

      Hi, have you ever tried building the query into a middleware? I'm having issues exporting my response. Any tips?

    • @kazenishi_Zyon
      @kazenishi_Zyon 3 года назад

      WHAT IS THIS ACCENT?

    • @kazenishi_Zyon
      @kazenishi_Zyon 2 года назад

      Man, very thanks for this video

  • @JuanChehin
    @JuanChehin 5 лет назад +30

    [04:40] : index.js
    [07:46] : express
    [18:24] : Insert an employees (Store procedure)
    [26:05] : Update an employees

  • @szabolcsjobbagy30
    @szabolcsjobbagy30 3 года назад +3

    At 11:10 I felt a CATHARTIC feeling, thank you mate!!
    That was the point when I understood the whole meaning of "API" and "backend". :)
    I started my learning path with courses on frontend, how to create simple webpages (HTML, CSS, JavaScript basics),
    then I learned the SQL queries of MS SQL and MySQL,
    and now I could connect the two with your help, thanks a lot!!

  • @tonyross2947
    @tonyross2947 4 года назад +12

    Good video. Just to make life easier at the start when you're creating a package.json file. If you type "npm init --yes", a file will be created without asking you any questions.

    • @nikhilshrivastava8411
      @nikhilshrivastava8411 4 года назад +2

      it can also work with npm init -y ..

    • @rjshukla_vlogs
      @rjshukla_vlogs 4 года назад

      awesome, without --yes it was giving error module not found. thanks for help :)

    • @CodAffection
      @CodAffection  4 года назад +2

      Thanks for the info.

  • @pillboxgaming4144
    @pillboxgaming4144 4 года назад +5

    Wow...simply wow. Took a bit for me to get everything installed and to work out my syntax errors but your tutorial is flawless. Thanks!

  • @MeganeFosteryukina
    @MeganeFosteryukina 4 года назад +6

    Amazing thank you , I'm used to use mysql for my project and when i saw for node everyone use mongodb , i learn mongodb but I'm really happy to see i tutorial for node and mysql so thank you :)

    • @ahmedjahmi5704
      @ahmedjahmi5704 3 года назад +1

      Hey yukina! Do you know of a video like this, but with mongodb instead of MySQL ? That would be really helpful! Thanks :)

  • @ChristopherAdams1
    @ChristopherAdams1 5 лет назад +14

    For anyone looking to copy and paste some SQL statements with some sample data for insert and just wanted to save some typing:
    use EmployeeDB;
    create table `employee` (
    `EmpID` int(11) not null auto_increment,
    `Name` varchar(45) default null,
    `EmpCode` varchar(45) default null,
    `Salary` int(11) default null,
    primary key (`EmpID`)
    ) engine=InnoDB auto_increment=0 default charset=utf8mb4;
    select * from employee;
    lock tables `employee` write;
    insert into `employee` values (1, 'Tommy Eatsheet', 'EMP90', 265400), (2, 'Jess Fukenson', 'EMP92', 50000),(3, 'Bob Knobhead', 'EMP95', 10000),(4, 'Dick knogginson', 'EMP96', 90000);

  • @chetangupta9622
    @chetangupta9622 4 года назад +2

    Thank you so much, I was searching for this from 7-8 hours but nothing found , Now I have done it in one try after this tutorial. Again thanks

  • @SanskritiSharma-mk7le
    @SanskritiSharma-mk7le 6 месяцев назад

    Thanks man! It really helped... I was searching on the internet since a long...finally found something useful...Nice explanation.

  • @AjaySharma-pg9wc
    @AjaySharma-pg9wc 2 года назад

    Thanks you i was looking for this entire RUclips and here i get my solution love from india😇

  • @sidneypalmeira1
    @sidneypalmeira1 6 лет назад +16

    Congrats, amazing tutorial, I imagined Node.js was a monster.

  • @vidyashree150
    @vidyashree150 День назад

    thank you so much, i was searching it for 1 week finally i got from this video it was excellent

  • @divakarkumarjha1171
    @divakarkumarjha1171 2 года назад +1

    Thanks sir I watched lots of video but that didn't worked for me but your video worked properly for thanks for such a great tutorial

  • @shahnilafahmi559
    @shahnilafahmi559 2 года назад +1

    Thankyou so much again for such a wonderful video that make me understand Node jS API and I can say I know Node js.

  • @williamsanchez4766
    @williamsanchez4766 2 года назад

    Awesome tutorial!
    Just had one question regarding the mysqlconnection.
    I noticed that you never actively closed your connection to the database. Will that cause issues in production, or are there underlying features within the packages used that help manage the connections as clients connect to your application?

  • @davidangelomendoza7636
    @davidangelomendoza7636 6 лет назад +6

    This is exactly what I was looking for. Thanks !

  • @saharabendjaballah8763
    @saharabendjaballah8763 4 года назад +3

    This was perfect thanks a lot. Just in case someone is using this today or in the near future, I had an error on workbench
    I changed the last line of code to this
    ENGINE=iNNOdb AUTO_INCREMENT=0 DEFAULT CHARSET=utf8
    and it worked just fine
    It was the only issue I had

  • @komaduraisamidurai7551
    @komaduraisamidurai7551 2 года назад

    it is very helpful and easy way to understand api thanks a lot

  • @akankhyasubudhi4406
    @akankhyasubudhi4406 4 года назад +1

    This is superb guidance tutorial for beginners

  • @luizfelipeburgattjolo6578
    @luizfelipeburgattjolo6578 3 года назад

    excelent, Brazil here, thx for help!

  • @mukulrana1616
    @mukulrana1616 2 года назад +1

    Great tutorial

  • @muskantripathi626
    @muskantripathi626 3 года назад +1

    Exactly what I needed, Thanks a lot :) Just a tip for those who are facing problem in inserting data to the database table - make EmpID AUTO_INCREMENT

    • @giribabu11
      @giribabu11 2 года назад

      but in my code auto increment is not working I don't know why

  • @ronakshah89
    @ronakshah89 4 года назад +1

    Very nicely explained Thank you!

  • @amansharma141
    @amansharma141 6 лет назад +3

    love your tuts..... plz make a tutorial on "WPF login(hashed) MVVM and EF7 CRUD application with online mysql database "

  • @johnnynguyenstudio2412
    @johnnynguyenstudio2412 2 года назад

    Thank you very much for the tutorial. It is the great tutorial I have met so far.

  • @omid443
    @omid443 5 лет назад

    It was the best tutorial I ever watched about GET,POST,PUT and DELETE

  • @alexisdauli8537
    @alexisdauli8537 4 года назад +1

    Started just in the beginning, I know that this is what I was looking for. Thanks

  • @aneeshahamed4216
    @aneeshahamed4216 4 года назад

    Thank you bro. You make easy to understand.
    How to write procedure in mysql(phpmyadmin)

  • @boismd
    @boismd 3 года назад

    thankyou, may i ask what is difference between put and post

  • @dineshvavilapalli5240
    @dineshvavilapalli5240 2 года назад

    Great!!!! easy explaination and simple script usage

  • @TheThird555
    @TheThird555 3 года назад

    Hello! Good tutorial! If you don't mind, could you please advise me, how to post query results to normal address, without port number. Seemingly i cannot post result to the page.

  • @ming8210
    @ming8210 4 года назад

    17:28 Did you mentioned 'ForceMan'? Why did you use it?

  • @anshulshrivastav7687
    @anshulshrivastav7687 3 года назад +1

    Very Nice, Very Easy

  • @TheDima23
    @TheDima23 2 года назад

    thank you so much, amazing tutorial here!

  • @SurajGupta-tc2pn
    @SurajGupta-tc2pn 3 года назад +1

    very helpful tutorial.

  • @mcaddit6802
    @mcaddit6802 3 года назад

    @raddy 's tutorial is awesome

  • @mayurkoli4145
    @mayurkoli4145 3 года назад

    if i refactor my code into multiple files eg. routes etc do i need to create mysqlConnection object for every page? please reply thank in advance :)

  • @BhaveshSinghBhanucsgo
    @BhaveshSinghBhanucsgo 3 года назад

    somebody plz tell how to connect this nodejs to angular for crup operations plzzzzzzz

  • @mohankadolkar1227
    @mohankadolkar1227 5 лет назад +1

    Excellent!. Concise, precise, direct and accurate. I tried mysql v8.0 initially. It threw error about authentication/authorization. Changed to mysql 5.6 and then everything went fine. Can you show how to work with mysql v8.0, the latest? Thanks.

    • @harshalpatil9346
      @harshalpatil9346 4 года назад

      +1

    • @tripathi5174
      @tripathi5174 3 года назад +1

      npm i mysql2 and then the following code in your index.js file const mysql = require('mysql2')
      var connection = mysql.createConnection({
      host : 'localhost',
      user : 'root',
      password : "&&&&"
      database : 'EmployeeDB'
      });
      connection.connect((err) => {
      if (!err)
      console.log('DB connection succeded.');
      else
      console.log('DB connection failed
      Error : ' + JSON.stringify(err, undefined, 2));
      });

    • @adeshsingh4039
      @adeshsingh4039 2 года назад +1

      @@tripathi5174 thank you so much, it worked for me..

  • @Manjaco
    @Manjaco 4 года назад +1

    For those who get this : ER_NOT_SUPPORTED_AUTH_MODE
    after doing node index.js
    this is error is mentioning when you install sql server you selected"strong authentication", but you set a weak password. You need to reset strong password or need to choose legacy authentication method.
    Follow these steps to choose legacy authentication method
    You installed mysql server using "mysql installer"
    1)open -> "mysql intsaller"
    2)press reconfig mysql server
    3)select left side "authentication method tab"
    4)select radio button -->use legacy authentication method
    5)now stop and restart the db
    and it should work

  • @shubhamprasad8352
    @shubhamprasad8352 4 года назад +1

    Nice tutorial!!

  • @anshumansinghrajawat7242
    @anshumansinghrajawat7242 3 года назад

    it was very helpful ,thankyou

  • @mdobyead7212
    @mdobyead7212 Год назад

    can you tell me how can i use this to create a login feature on my HTML website using nodejs and mysqlworkbench

  • @madhukarreddy4022
    @madhukarreddy4022 3 года назад

    Thank you so much, it is help me a lot, how to display data in html table?

  • @HuzaifaJalali
    @HuzaifaJalali 4 года назад +4

    The table creation data:
    CREATE TABLE `employee` (
    `EmpId` INT(11) NOT NULL AUTO_INCREMENT,
    `Name` VARCHAR(45) DEFAULT NULL,
    `EmpCode` VARCHAR(45) DEFAULT NULL,
    `Salary` INT(11) DEFAULT NULL,
    PRIMARY KEY (`EmpId`))
    ENGINE = InnoDB AUTO_INCREMENT=0;

  • @yowtf5597
    @yowtf5597 2 года назад +1

    literally killed me with your joke 7:25

  • @albertogandarillas657
    @albertogandarillas657 3 года назад

    Thank you so much , very clear tutorial it really helps me !

  • @js_programmer8423
    @js_programmer8423 4 года назад

    What online cloud database do we use to migrate/deploy the mysql workbench database?

  • @jeevithathangaraj590
    @jeevithathangaraj590 4 года назад +1

    hello codeAffection can you make the same thing for nodejs+postgresql the connection,how to insert,update,delete using the post,get,put http request can you??

  • @omid443
    @omid443 5 лет назад +1

    in 22:24 when you made a variable and called it SQL you add '@' behind each of the request data like 'set @empId = ?' I want to know why?
    I can't just do the POST!

  • @godsonprogrammer2807
    @godsonprogrammer2807 6 лет назад +2

    You can also use MySQL server of XAMPP

  • @healthychoice4308
    @healthychoice4308 3 года назад

    tq....exactly wat i needed ....great tutorial

  • @mkhalidumer
    @mkhalidumer 6 лет назад

    Thanks for your efforts and time - Dotnet Mob, Just a small question if you have time, how we can use this node project as back-end for angular

    • @CodAffection
      @CodAffection  6 лет назад

      Node.js act as back-end in MEAN stack applications with Angular(front-end).

    • @mkhalidumer
      @mkhalidumer 6 лет назад

      Yes that is ok but, my interest is how to do this?

    • @CodAffection
      @CodAffection  6 лет назад +2

      Within 1 week, I'll upload a video tutorial on this topic.

    • @mkhalidumer
      @mkhalidumer 6 лет назад

      Tusi Great Ho Paa Jee,

    • @CodAffection
      @CodAffection  6 лет назад +1

      MEAN Stack CRUD Operations : ruclips.net/video/UYh6EvpQquw/видео.html

  • @AbhishekSingh-dt6br
    @AbhishekSingh-dt6br 2 года назад

    Thank you so much brother. This is exactly what I wanted. 😁

  • @Trinita1970
    @Trinita1970 4 года назад +1

    thank you

  • @mervinrodrigues192
    @mervinrodrigues192 3 года назад

    Thank You so much made my day :)

  • @EDW4RD249
    @EDW4RD249 3 года назад

    Thank you man, a very clear explanation!

  • @Abhinav_Sharma_07
    @Abhinav_Sharma_07 5 лет назад +1

    IF U CREATE STORED PROCEDURE IN MYSQL USING XAMPP,
    THEN IST LINE IS
    CREATE PROCEDURE PROCEDURENAME(
    PROCEDURENAME IS NOT BETWEEN ANY SEMICOLONS
    AND USE DELIMETER AS //

  • @1chaplain
    @1chaplain 4 года назад +1

    Indian coding YTbers are carrying us through quarantine projects/assignments

  • @BhaveshSinghBhanucsgo
    @BhaveshSinghBhanucsgo 3 года назад

    love u bro

  • @songwright
    @songwright 4 года назад +1

    Integer display width is deprecated. You don't need it, you just need 'int'.

  • @Vinodkumar-sh9oj
    @Vinodkumar-sh9oj 4 года назад

    Why did you use stored procedure instead of normal query, is there any reason ?

  • @panjigemilang2077
    @panjigemilang2077 4 года назад

    sir, you didn't show how to make the model with for example sequelize?

  • @sudhir600
    @sudhir600 6 лет назад

    thanks man.. what a great video.. easy and sharp... you saved my day. I appreciate your work.

    • @CodAffection
      @CodAffection  6 лет назад +1

      Glad you found the video helpful.

  • @mahmoodimtiaz2550
    @mahmoodimtiaz2550 5 лет назад +1

    Great! How to integrate API key with GET ,POST,PUT and DELETE request??

    • @syedfaruck8652
      @syedfaruck8652 5 лет назад

      salaam,Mr.Imtiaz this is syed could u pls teach me about put and delete method in node js(REST API)
      7845136318

  • @ravikuamr1993
    @ravikuamr1993 3 года назад +1

    How to you run index.js file in command prompt. Here i can not run node index.js file.

  • @charlesliu9768
    @charlesliu9768 6 лет назад

    The video is very useful for me, thanks for your excellent job.

  • @shahnilafahmi559
    @shahnilafahmi559 2 года назад

    This is my Request to give me suggestion that how can I write API with MS Sql Server ....What are connections and packages ?

  • @abdallahyaghi8463
    @abdallahyaghi8463 4 года назад +1

    Thank you so much

  • @umreddy4855
    @umreddy4855 5 лет назад

    Thank you very much sir. Excellent tutorial.

  • @CrazyEvo5
    @CrazyEvo5 6 лет назад +1

    Wouldn't setting multiple statements variable to true put your db at risk for query injection? Very easy tutorial to follow along with though...

  • @mridulburagohain3548
    @mridulburagohain3548 3 года назад

    very good tutorial !

  • @akshatbhardwaj4026
    @akshatbhardwaj4026 5 лет назад

    Very helpful video. Thank you so much!

    • @CodAffection
      @CodAffection  5 лет назад +1

      glad you found the video helpful.

  • @shahankitj
    @shahankitj 5 лет назад +1

    Thanks for the gr8 video but getting following error if you can help
    err {
    "code": "ER_NOT_SUPPORTED_AUTH_MODE",
    "errno": 1251,
    "sqlMessage": "Client does not support authentication protocol requested by server; consider upgrading MySQL client",
    "sqlState": "08004",
    "fatal": true

    • @shahankitj
      @shahankitj 5 лет назад +1

      found the solution after few research...

    • @shahankitj
      @shahankitj 5 лет назад +2

      open MySQL command line client and run
      ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '****';
      it will change authentication type to standard which will allow to connect

  • @randomnet_tv
    @randomnet_tv 6 лет назад +1

    Good tutorial. Would have been better if you added a front-end to do the CRUD requests rather than using postman

  • @gauthambekal235
    @gauthambekal235 6 лет назад

    Superb explanation Sir.

  • @linden6705
    @linden6705 5 лет назад

    Exactly what I needed, great tutorial!

  • @bhattaraitheaxe
    @bhattaraitheaxe 3 года назад

    Awesome 👏

  • @Jun-zq3bn
    @Jun-zq3bn 3 года назад +1

    how can I link the routes with a front end user interface whereby my user can fetch all the data by clicking on a button?

  • @blu5037
    @blu5037 4 года назад

    Thank you very much for making this :)

    • @CodAffection
      @CodAffection  4 года назад

      No problem 😊, let me know if you have any suggestion for upcoming tutorial ?

  • @102030anurag
    @102030anurag 5 лет назад +3

    I am getting the message DB connection succeded... but when passing /employees I am not seeing the table record

  • @bhushandewang2407
    @bhushandewang2407 6 лет назад +2

    hello sir pls provide information about how to download mysql and how to connect it with angular6

    • @godsonprogrammer2807
      @godsonprogrammer2807 6 лет назад

      you can download the MySQL Workbench that's used in this video from dev.mysql.com/downloads/workbench/

    • @godsonprogrammer2807
      @godsonprogrammer2807 6 лет назад

      You can also use MySQL server of XAMPP

  • @varaprasad4163
    @varaprasad4163 4 года назад

    where can I find that copy paste query? please let me know.

  • @someoneoutthere1866
    @someoneoutthere1866 4 года назад

    Very good video!!!!

  • @alimirza3271
    @alimirza3271 5 лет назад

    what about if it not storedprocedure table then what will be the query???? kindly help me

  • @joeballer4036
    @joeballer4036 5 лет назад +1

    Where is the front end for this app? I would like to see the end result before beginning the tutorial.
    Thanks

  • @cellocarlos
    @cellocarlos 5 лет назад

    Why do you use Stored Procedure instead of direct sql statement? And Why do you use multiple statement and create variables instead of just using EmployeeAddOrEdit(?, ?, ?, ?);
    Thanks.

    • @CodAffection
      @CodAffection  5 лет назад

      I chose stored procedure because it
      - prevent from sql injection
      - better performance due to execution plan.
      I didn't get your second question.

    • @cellocarlos
      @cellocarlos 5 лет назад

      @@CodAffection I mean, you declare variables and assign value to them, then you use those variable inside the call to EmployeeAddOrEdit(). Why don't you just use the params already inside the call to the stored procedure? It is, why do you use EmployeeAddOrEdit(@EmpID, @Name, @EmpCode, @Salary) instead of EmployeeAddOrEdit(?, ?, ?, ?) ?

    • @CodAffection
      @CodAffection  5 лет назад +1

      it would make the code more readable.

    • @cellocarlos
      @cellocarlos 5 лет назад

      @@CodAffection Got it. Thanks a lot

  • @alyhassan4877
    @alyhassan4877 4 года назад

    amazing video help alot , if anyone had same error as me can tell me the reason
    the id is auto incremented by 2 like first element is 2 and the second is 4 etc..

  • @jaywantnarwade4775
    @jaywantnarwade4775 5 лет назад

    NIce Tutorial. Its very helpfull to me.

  • @rude_boyie
    @rude_boyie 5 лет назад

    so how do i reopen the workspace when it shows me this?
    [Info - 8:26:41 PM] ESLint server stopped.
    [Info - 8:26:42 PM] ESLint server running in node v10.11.0
    [Info - 8:26:42 PM] ESLint server is running.
    [Info - 8:26:45 PM]
    Failed to load the ESLint library for the document c:\Users
    w888\Desktop\project\package.json
    To use ESLint please install eslint by running npm install eslint in the workspace folder project
    or globally using 'npm install -g eslint'. You need to reopen the workspace after installing eslint.
    If you are using yarn or pnpm instead of npm set the setting `eslint.packageManager` to either `yarn` or `pnpm`
    Alternatively you can disable ESLint for the workspace folder project by executing the 'Disable ESLint' command.
    [Info - 8:26:45 PM]
    Failed to load the ESLint library for the document c:\Users
    w888\Desktop\project\index.js

  • @md.shuaibsiddiqui1019
    @md.shuaibsiddiqui1019 6 лет назад

    Hello Sir,very very Thanks for this awesome tutorial...Sir i beg to request u plzzz make tutorial for node js crud using angular js..waiting for ur response...

    • @CodAffection
      @CodAffection  6 лет назад

      please try this : ruclips.net/video/UYh6EvpQquw/видео.html
      Angular + NodeJS + Express + MongoDB (Mean Stack)

  • @nrusinghabarik363
    @nrusinghabarik363 6 лет назад

    Thanks a lot for nice video tutorial

  • @AD-Zain
    @AD-Zain 4 года назад

    Thanks for nice video. But the problem Sql and NodeJs is, how to handle one-many-table without repeating the data like [{id:1, images:[image1, image3, ...]}]

  • @shitalkarlekar7198
    @shitalkarlekar7198 4 года назад

    You are a awesome. your video really helpful for me. thank you ..

    • @CodAffection
      @CodAffection  4 года назад

      Thanks, let me know if you have any video suggestion related to node js.

  • @sanelisosimelane6317
    @sanelisosimelane6317 6 лет назад

    awesome clean video I am from a Java background, this has been successfully helpful.

  • @Cuisine-Code-with-Manisha
    @Cuisine-Code-with-Manisha 3 года назад

    How to create this procedure in Ubuntu terminal??

  • @mansilaad2062
    @mansilaad2062 3 года назад

    Sir please make some more videos on restful api with express+mysql

  • @varaprasad4163
    @varaprasad4163 4 года назад

    I'm tired of trying connection node to mysql. im getting db connection failed. tried so many times but still getting an error. please help me out. And your explaination was awesome.

  • @paradoxstudio2826
    @paradoxstudio2826 5 лет назад +2

    How would you do a PATCH request for this project

    • @destro697
      @destro697 3 года назад

      PUT and PATCH are used for updating so you could use PATCH in the same way as PUT

  • @로버트-p3e
    @로버트-p3e 6 лет назад

    This was a really good tutorial for me.
    However, when I perform a POST action through Postman, I get Insert only when EmpID is zero.
    If I send a value other than 0 to EmpID via Json, a Success message appears but no data is stored in the DB.
    Can you help?

    • @CodAffection
      @CodAffection  6 лет назад

      if you send a json object with non zero id, it will try to update the record with given id. if there is no such employee nothing will happen.
      better in client side app you can add validation or add validation in nodejs like if id is a non zero value then show some warning message.