Closed ltoddy closed 2 years ago
Hey @ltoddy, is there any special reason for you to use mysql_async
instead of sqlx
?
No. Sometimes, the database used by developer is a cloud database. For example, mysql. The database client actually connects to the proxy, not the database itself . In other words, connecting to the database is through service discovery not IP address. Therefore, cloud service providers provide SDKs for service discovery, and SDK return the db handler.
其实意思就是,使用云服务商提供的数据库,是通过服务发现的方式来连接数据库的,用户是不知道数据库真是的ip地址的。 使用云服务商提供的sdk,只能得到一个db handler,比如他们基于async_mysql库自己做了一个库,支持上了服务发现的方式去连接。 这样子,就无法使用sea-orm了。 所以,如果sea-orm支持了通过一个数据库连接,来得到sea-orm的DBConnection对象,这样子就可以使用sea-orm来连接云数据库了。
Take Planetscale as an example, you have no fixed ip address access to the cloud db. But you can connect to it with a connection string mysql://jp388djdawnod:pscale_pw_sVkiE_m1111111111111111@gxvhbzcxfw01.us-east-2.psdb.cloud/<DATABASE_NAME>
REF: https://docs.planetscale.com/tutorials/connect-any-application
Your example uses the MySQL connection protocol header . But In my life, dsn like: "sd@
I guess you have to specify the db protocol at the front, db_protocal://sd@<service_name>/<db_name>
Not in front. The process of parsing the protocol is:
sd@<service_name>/<db_name>
Seems you can perform the first two steps without sea-orm?
- service discovery read the DSN which like
sd@<service_name>/<db_name>
- client send request to service discovery center by
to get database proxy ip address
After you get the concrete IP then you can initialize the connection with sea-orm. e.g. protocol://username:password@host/database
- client establish connection with database proxy.
- client send sql to db proxy, and then proxy send sql to db to execute it.
Please correct me if I'm wrong
I think the best way to move forward is for you to request a support for SeaORM from THEM. Then instruct them to contact us. We might be able to work something out together as a commercial offering. Otherwise, we will not be able to support a cloud vendor's proprietary solution.
e.g.