sqlitecloud / sdk

Official SDK repository for SQLite Cloud databases and nodes.
https://sqlitecloud.io
29 stars 2 forks source link

Add connection string support to PHP #2

Closed marcobambini closed 2 months ago

marcobambini commented 2 months ago

In the current PHP version a connect method exists but we should extend the SDK to accept also a connection string like in the C SDK: https://github.com/sqlitecloud/sdk/blob/2e6aa0b3cacc737526f35b30b8289dcf4a6608e5/C/sqcloud.c#L2439

The connection string is a string in the format: sqlitecloud://user:pass@host.com:port/dbname?timeout=10&key2=value2&key3=value3 username and password are optional (like dbname) and an apikey can be passed as parameter to authenticate.

User can copy a connection string from within the dashboard as use it as-is to connect to any node. For a list of the currently supported keys see: https://github.com/sqlitecloud/sqlitecloud-js/issues/68#issuecomment-2055450382

See code in https://github.com/sqlitecloud/sdk/blob/2e6aa0b3cacc737526f35b30b8289dcf4a6608e5/C/sqcloud.c#L1626 to check which command to use for each setting. Please note that you can append more command into a single one separated by the ; character to minimize the latency and improve performance.