0

Can I execute sql sentences in javacript without calling an external php file?

I have seen that I can use SQL with node.js easily but, I'm useing Vue.js and it's my first time so i'm a little bit confused.

In summary, I want to connect to a database without useing php and I don't know if it would work.

Thanks you!

Milad Aghamohammadi
  • 1,866
  • 1
  • 16
  • 29
David Benitez Riba
  • 848
  • 1
  • 9
  • 11
  • Where is that SQL database located? – x-ray Oct 06 '18 at 11:42
  • 5
    Client side js can't connect to a sql server on it's own. If you could, it would be a serious security issue as well, since everyone could check the source and get the credentials and make what ever calls to the database they want. – M. Eriksson Oct 06 '18 at 11:42
  • If it's on a server, you simply can't using just front end tools. Voted to close, since this is not a specific problem but rather looking for a tutorial. – naeramarth7 Oct 06 '18 at 11:43
  • You cant !! not with frontend library whether its vue,angular or vanilla js .you just cant. You be needing any middlelayer like php or node.js for creating database connection. – Shubham Dixit Oct 06 '18 at 11:49
  • Ok thanks, it was just a crazy idea. – David Benitez Riba Oct 06 '18 at 11:54
  • You might want to read up on [What is the difference between client-side and server-side programming?](https://stackoverflow.com/questions/13840429/what-is-the-difference-between-client-side-and-server-side-programming). Node and PHP are server side while vue is a client side library. Everything that's client side is downloaded to the users client and can be read and manipulated by the users. – M. Eriksson Oct 06 '18 at 11:56

1 Answers1

1

if you want to develop only javascript, it is possible to use node.js server (alternative apache, nginx etc.)

For communication with db we can recommend framework Express and easy connect any sql

OtiK.cz
  • 95
  • 4