@@ -114,9 +114,10 @@ static void do_print_usage (void) {
114114 printf (" -p PORT port to connect to (default %d)\n" , SQCLOUD_DEFAULT_PORT );
115115 printf (" -f FILEPATH file path with commands to execute\n" );
116116 printf (" -d DATABASE database name\n" );
117+ printf (" -s CONNECTIONSTRING connection string\n" );
117118 printf (" -r ROOT_CERTIFICATE path to root certificate for TLS connection\n" );
118- printf (" -s CLI_CERTIFICATE path to client certificate for TLS connection\n" );
119- printf (" -t CLI_KEY path to client key certificate for TLS connection\n" );
119+ printf (" -t CLI_CERTIFICATE path to client certificate for TLS connection\n" );
120+ printf (" -k CLI_KEY path to client key certificate for TLS connection\n" );
120121 printf (" -u TIMEOUT connection timeout in seconds (default no timeout)\n" );
121122 printf (" -y IP connection type (IPv4, IPv6 or IPany, default IPv4)\n" );
122123 printf (" -n USERNAME authentication username\n" );
@@ -479,6 +480,7 @@ int main(int argc, char * argv[]) {
479480 const char * password = NULL ;
480481 const char * filename = NULL ;
481482 const char * database = NULL ;
483+ const char * connstring = NULL ;
482484 const char * root_certificate_path = NULL ;
483485 const char * client_certificate_path = NULL ;
484486 const char * client_certificate_key_path = NULL ;
@@ -510,15 +512,16 @@ int main(int argc, char * argv[]) {
510512 case 'w' : linebyline = false; break ;
511513 case 'd' : database = optarg ; break ;
512514 case 'r' : root_certificate_path = optarg ; break ;
513- case 's ' : client_certificate_path = optarg ; break ;
514- case 't ' : client_certificate_key_path = optarg ; break ;
515+ case 't ' : client_certificate_path = optarg ; break ;
516+ case 'k ' : client_certificate_key_path = optarg ; break ;
515517 case 'u' : timeout = atoi (optarg ); break ;
516518 case 'y' :
517519 if (strcasestr (optarg , "IPv6" ) != 0 ) {family = SQCLOUD_IPv6 ;}
518520 else if (strcasestr (optarg , "IPany" ) != 0 ) {family = SQCLOUD_IPANY ;}
519521 break ;
520522 case 'n' : username = optarg ; break ;
521523 case 'm' : password = optarg ; break ;
524+ case 's' : connstring = optarg ; break ;
522525 }
523526 }
524527
@@ -535,24 +538,30 @@ int main(int argc, char * argv[]) {
535538 config .family = family ;
536539 config .timeout = timeout ;
537540
538- // setup TLS config parameter
539- #ifndef SQLITECLOUD_DISABLE_TLS
540- if (insecure ) config .insecure = true;
541- if (noverifycert ) config .no_verify_certificate = true;
542- if (root_certificate_path ) config .tls_root_certificate = root_certificate_path ;
543- if (client_certificate_path ) config .tls_certificate = client_certificate_path ;
544- if (client_certificate_key_path ) config .tls_certificate_key = client_certificate_key_path ;
545- #endif
546-
547- if (sqlite ) config .sqlite_mode = true;
548- if (zerotext ) config .zero_text = true;
549- if (compression ) config .compression = true;
550- if (database ) config .database = database ;
551- if (username ) config .username = username ;
552- if (password ) config .password = password ;
553-
554541 // try to connect to hostname:port
555- SQCloudConnection * conn = SQCloudConnect (hostname , port , & config );
542+ SQCloudConnection * conn = NULL ;
543+ if (connstring ) {
544+ conn = SQCloudConnectWithString (connstring , & config );
545+ } else {
546+ // setup TLS config parameter
547+ #ifndef SQLITECLOUD_DISABLE_TLS
548+ if (insecure ) config .insecure = true;
549+ if (noverifycert ) config .no_verify_certificate = true;
550+ if (root_certificate_path ) config .tls_root_certificate = root_certificate_path ;
551+ if (client_certificate_path ) config .tls_certificate = client_certificate_path ;
552+ if (client_certificate_key_path ) config .tls_certificate_key = client_certificate_key_path ;
553+ #endif
554+
555+ if (sqlite ) config .sqlite_mode = true;
556+ if (zerotext ) config .zero_text = true;
557+ if (compression ) config .compression = true;
558+ if (database ) config .database = database ;
559+ if (username ) config .username = username ;
560+ if (password ) config .password = password ;
561+
562+ conn = SQCloudConnect (hostname , port , & config );
563+ }
564+
556565 if (SQCloudIsError (conn )) {
557566 printf ("ERROR connecting to %s: %s (%d)\n" , hostname , SQCloudErrorMsg (conn ), SQCloudErrorCode (conn ));
558567 return -1 ;
0 commit comments