使用Angular访问数据库 [英] Database access with Angular

查看:50
本文介绍了使用Angular访问数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在Angular框架中访问MySQL数据库,或者像其他Javascript一样不安全,我将需要发布到PHP页面以从数据库中检索 data/json

Is it possible to access MySQL databases in Angular framework or would that be insecure like other Javascript and I will need to post to a PHP page to retrieve data/json from a database

推荐答案

1-是否可以在角度框架中访问MySQL数据库?

1- Is it possible to access MySQL databases in angular framework?

问题不是特定于角度的,而是是可能,因为MySQL 5.7可以通过HTTP在MySQL中插入,更新和删除记录.像这样http://127.0.0.1:8080/sql/myhttp/SELECT+name_first、+name_last+FROM+名称

The question is not angular specific but YES It's possible , since MySQL 5.7 inserting, updating and deleting records in MySQL via HTTP is possible. Something like this http://127.0.0.1:8080/sql/myhttp/SELECT+name_first,+name_last+FROM+names refer here

因此,您可以使用以下任何HTTP客户端直接与MySQL进行交互:淘汰任何中间件.

Hence you can interact with MySQL directly with any HTTP client with out any middle-ware.

通过HTTP客户端,我的意思是Curl,Wget或任何语言的任何Http库/API(针对JavaScript/节点的ajax,request,fetch,axios ...)

By HTTP Client I mean Curl,Wget or any Http library/API of any language (ajax,request,fetch,axios ... for JavaScript/node)

2-像其他JavaScript一样不安全吗?

2 - Would that be insecure like other JavaScript?

同样不是特定于JavaScript的,但是是的,不安全(不推荐)直接从客户端与数据库进行交互.为什么?您需要从客户端(在这种情况下为角度)处理数据库安全性问题,例如SQL注入.这样做很不方便.

Again not JavaScript specific, But Yes it's insecure(not recommended) to directly interact with the database from the client. Why? You need to handle database security issues like SQL Injection from the client side (angular in this case). It's is very inconvenient to do that.

我建议始终使用数据库访问中间件(php,node,python ...)比从客户端进行交互

I do recommend to always have database access middle-ware (php,node,python ...) than interacting from client side

这篇关于使用Angular访问数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆