What is the preferred way in Poco to issue the equivalent of the SQL USE mychosendb
command via the MySQL data connector?
The introductory example to using Poco Data libraries indicates that the database one selects for use is a property/parameter of the Session
object. Documentation on the Session
object is sparse, but sufficient to be confident that the database is specified as part of a connectionString
parameter. If that is true, what is the format of this string?
Information from connectionstrings.com suggests a connection string including database=mychosendb
should be equivalent to the SQL USE mychosendb
command. So far I cannot see a way to make either of the two obvious approaches work:
- my existing connection string in the form
host=localhost;user=mylogin;password=mypassword
works fine, but does not specify a database; when I add variations ondatabase=mychosendb
to the string, it seems to be ignored. - trying to execute an SQL
USE
command informs me that this is not a command supported by this interface.
Sigh. It's the blindingly-obvious-once-you-know-but-not-before case of needing to use the abbreviated
db=mychosendb
instead of any longer formdatabase=mychosendb
orDatabase=mychosendb
- neither of the latter work, at least not for me.Whether or not this is the preferred method, I don't know. But I know it works.