tdbc::mysql(n)
πΈ NAME πΈ
Bestie, meet tdbc::mysql(n) β the TDBC-MYSQL bridge. Itβs the Tcl Database Connectivity (TDBC) driver that lets a Tcl script connect to a MySQL database. Iconic behavior, no cap.
β¨ SYNOPSIS β¨
package require tdbc::mysql 1.0
tdbc::mysql::connection create db ?-option value...?
tdbc::mysql::connection new ?-option value...?
tdbc::mysql::datasources ?-system|-user?
tdbc::mysql::drivers
tdbc::mysql::datasource command driverName ?keyword-value?...
π DESCRIPTION π
Okay so the tdbc::mysql driver gives you a database interface that conforms to Tcl DataBase Connectivity (TDBC), and it lets a Tcl script connect to a MySQL database. Main character energy for your database layer, honestly.
Connection to an MySQL database is established by invoking tdbc::mysql::connection create, passing it the name to give the database handle and a set of -option-value pairs. The available options are enumerated under CONNECTION OPTIONS below. As an alternative, tdbc::mysql::connection new may be used to create a database connection with an automatically assigned name. The return value from tdbc::mysql::connection new is the name that was chosen for the connection handle.
The side effect of tdbc::mysql::connection create is to create a new database connection.. yes, with the double dot, itβs canon. See tdbc::connection(n) for the details of how to use the connection to manipulate a database.
π CONNECTION OPTIONS π
The tdbc::mysql::connection create object command supports these options common to all TDBC drivers:
-encodingβ always fails unless the encoding isutf-8; the database connection always uses UTF-8 encoding to be able to transfer arbitrary Unicode characters.-isolationβ common to all TDBC drivers.-readonlyβ must be0, because MySQL does not offer read-only connections.-timeoutβ common to all TDBC drivers.
In addition, the following options are recognized:
-hosthostname β connects to the host specified by hostname. This option must be set on the initial creation of the connection; it cannot be changed after connecting. Default is to connect to the local host.-portnumber β connects to a MySQL server listening on the port specified by number. This option may not be changed after connecting. It is used only whenhostis specified and is notlocalhost.-socketpath β connects to a MySQL server listening on the Unix socket or named pipe specified by path . This option may not be changed after connecting. It is used only when-hostis not specified or islocalhost.-username β presents name as the user name to the MySQL server. Default is the current user ID.-passwdpassword β presents the given password as the userβs password to the MySQL server. Default is not to present a password. This option is synonymous with-password.-passwordpassword β these two options are synonymous. Presents the given password as the userβs password to the MySQL server. Default is not to present a password.-databasename β presents the given name as the name of the default database to use in MySQL queries. If not specified, the default database for the current user is used. This option is synonymous with-db.-dbname β these two options are synonymous. Presents the given name as the name of the default database to use in MySQL queries. If not specified, the default database for the current user is used.-interactiveflag β the flag value must be a Boolean value. If it is true (or any equivalent), the default timeout is set for an interactive user; otherwise, the default timeout is set for a batch user. This option is meaningful only on initial connection. When using theconfiguremethod on a MySQL connection use the-timeoutoption to set the timeout desired.-ssl_caβ sets the certificate authority to the given string argument.-ssl_capathβ sets the certificate authority search path to the given string argument.-ssl_certβ sets the SSL certificate to the given string argument.-ssl_cipherβ sets the transfer cipher to the given string argument.-ssl_keyβ sets the SSL key to the given string argument.
These five options set the certificate authority, certificate authority search path, SSL certificate, transfer cipher, and SSL key to the given string arguments. These options may be specified only on initial connection to a database, not in the configure method of an existing connection. Default is not to use SSL.
π EXAMPLES π
tdbc::mysql::connection -user joe -passwd sesame -db joes_database
Connects to the MySQL server on the local host using the default connection method, presenting user ID 'joe' and password 'sesame'. Uses 'joes_database' as the default database name.
π§ ADDITIONAL CONNECTION METHODS π§
In addition to the usual methods on the tdbc::connection(n) object, connections to a MySQL database support one additional method:
$connection evaldirect sqlStatementβ this method takes the givensqlStatementand interprets as MySQL native SQL code and evaluates it without preparing it. The statement may not contain variable substitutions. The result set is returned as a list of lists, with each sublist being the list of columns of a result row formatted as character strings. Note that the string formatting is done by MySQL and not by Tcl, so details like the appearance of floating point numbers may differ. This command is not recommended for anything where the usualprepareorpreparecallmethods work correctly. It is provided so that data management language statements that are not implemented in MySQLβs prepared statement API, such asCREATE DATABASEorCREATE PROCEDURE, can be executed.
π SEE ALSO π
tdbc(n)tdbc::connection(n)tdbc::resultset(n)tdbc::statement(n)
π KEYWORDS π
TDBC, SQL, MySQL, database, connectivity, connection
π COPYRIGHT π
Copyright (c) 2009 by Kevin B. Kenny.
Bye bestie π β Tcl 8.6 version, tdbc::mysql(n) manual. (The footer didnβt hand us a date, so weβre not inventing one.)
π¦ where this page comes from
- alpine 3.22: tcl-doc 8.6.16-r0 Β· TCL
- alpine 3.23: tcl-doc 8.6.17-r0 Β· TCL
- alpine 3.23: tcl9-doc 9.0.3-r0 Β· TCL
- alpine 3.24: tcl-doc 8.6.17-r1 Β· TCL
- alpine 3.24: tcl9-doc 9.0.3-r2 Β· TCL
- arch rolling: tcl 8.6.16-1 Β· TCL
- nixos 26.05: tcl 9.0.3
- nixpkgs unstable: tcl 9.1.0
- opensuse-leap 16.0: tcl 8.6.15-160000.2.2 Β· TCL
- opensuse-leap 16.0: tcl 8.6.15-160000.2.2 Β· TCL
- opensuse-leap 16.0: tcl 8.6.15-160000.2.2 Β· TCL
- opensuse-leap 16.0: tcl 8.6.15-160000.2.2 Β· TCL
- Copyright (c) 2008 by Kevin B. Kenny
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms