====== MySQL TCL ====== ===== Syntaxe ===== ::mysql::connect ?option value...? ::mysql::use handle database ::mysql::sel handle sql-statement ?-list|-flatlist? ::mysql::fetch handle ::mysql::exec handle sql-statement ::mysql::query handle sql-select-statement ::mysql::endquery query-handle ::mysql::map handle binding-list script ::mysql::receive handle sql-statment binding-list script ::mysql::seek handle row-index ::mysql::col handle table-name option ::mysql::col handle table-name optionkist ::mysql::col handle ?option...? ::mysql::info handle option ::mysql::baseinfo option ::mysql::ping handle ::mysql::changeuser user password ?database? ::mysql::result handle option ::mysql::state handle ?-numeric? ::mysql::close ?handle? ::mysql::insertid handle ::mysql::escape ?handle? string ::mysql::autocommit handle boolean ::mysql::commit handle ::mysql::rollback handle ::mysql::nextresult handle ::mysql::moreresult handle ::mysql::warningcount handle ::mysql::isnull value ::mysql::newnull ::mysql::setserveroption handle option ::mysql::shutdown handle ::mysql::encoding handle ?encoding? ===== Description ===== MySQLTcl is a collection of Tcl commands and a Tcl global [[:tcl:array]] that provide access to MySQL database servers. MySQLTcl is nothing more than a patched version of a patched version of Hakan Soderstrom's patch of Tom Poindexter's Sybtcl. Mysqltcl is binary Tcl library (extension) written in C language that use direkt official MySQL C-API. Almost all Tcl commands correspond to MySQL C-API functions. For detail documentation see official MySQL C-API manual. ==== connect ==== ::mysql::connect ?option value...? Connect to a MySQL server. A handle is returned which should be used in other mysqltcl commands using this connection. ::mysql::connect raises a Tcl error if the connection fails. ::mysql::connect read first the options from my.cnf file group mysqltcl. See MySQL documentation chapter "options files". Possible connection options are: * **-host //hostname//** : The host on which the server is located. The local host is used by default. * **-user //user//** : The user whose name is used for the connection. The current Unix user-name is used by default. * **-password //password// : The password that must be used for the connection. If it is not present, the connection is possible only for users with no password on the server. * **-db //db//** : If this option is present, db is used as current database, with no need for a call to mysql::use. * **-port //port// : The port number for the TCP/IP connection, if it's different from the default. * **-socket //socket//** : The socket or named pipe for the connection. * **-encoding //encodingname//** : The option works similar to **-encoding** option in [[:tcl:fconfigure]]. It support also special encoding name binary. By option **-binary** no converting will be done be reading or writing to/from MySQL. If option is not set the system encoding (see utf-8) is used. Please test all input and outputs with another program to check that all is the way you expect it. If option binary is not used the system procedures Tcl_ExternalToUtfDString (writing) and Tcl_ExternalToUtf (reading) will be used by option binary the function Tcl_GetByteArrayFromObj and Tcl_NewByteArrayObj are used. If you want to manipulate binary date use -encoding binary. By handling textes set your special encoding that you want to use in your database. Consider what another system access the database and what encoding they expect. It can useful to use -encoding utf-8. That is standard encoding in some linux distributions and newer systems. * **-compress //boolean//** : Use compression protocol. Default is false * **-odbc //boolean//** : The client is an ODBC client. This changes mysqld to be more ODBC-friendly. Default is false * **-noschema //boolean//** : Don't allow the db_name.tbl_name.col_name syntax. This is for ODBC. It causes the parser to generate an error if you use that syntax, which is useful for trapping bugs in some ODBC programs. This changes mysqld to be more ODBC-friendly. Default is false * **-multistatement //boolean//** : Tell the server that the client may send multiple-row-queries (separated by ;). If this flag is not set, multiple-row-queries are disabled. Default is false. * **-multiresult //boolean//** : Tell the server that the client can handle multiple-result sets from multi-queries or stored procedures. This is automatically set if CLIENT_MULTI_STATEMENTS is set. * **-localfiles //boolean//** : Enable LOAD DATA LOCAL handling. Default is false. * **-foundrows //boolean//** : Return the number of found (matched) rows, not the number of affected rows. Default is false. * **-interactive //boolean//** : Allow interactive_timeout seconds (instead of wait_timeout seconds) of inactivity before closing the connection. The client's session wait_timeout variable will be set to the value of the session interactive_timeout variable. Default is false. * **-ssl //boolean//** : Switch to SSL after handshake. Default is false * **-sslkey //string//** is the pathname to the key file. Used if -ssl is true * **-sslcert //string//** is the pathname to the certificate file. Used if -ssl is true * **-sslca //string//** is the pathname to the certificate authority file. Used if -ssl is true * **-sslcapath //string//** is the pathname to a directory that contains trusted SSL CA certificates in pem format. Used if -ssl is true * **-sslcipher //string//** is a list of allowable ciphers to use for SSL encryption. Used if -ssl is true ==== use ==== ::mysql::use handle database Associate a connected handle with a particular database. handle must be a valid handle previously obtained from ::mysql::connect. mysql::use raises a Tcl error if the handle is not valid or if the database name specified could not be used. Consider you can use mysqltcl without to specify the database, in this case you must use explizit schema notation to specify the table in sql. ::mysql::sel $handle {select * from uni.student} with option //[[#connect]] -noschema// you can prohibit such syntax. ===== Exemples ===== ===== Voir aussi ===== [[:tcl:package:]], http://www.xdobry.de/mysqltcl/mysqltcl.html {{tag>package incomplete translation databases}}