Use Python to operate MySQL database instancesInstall the mysql module on Windows for Python Development
When using python to connect to mysql, you need to use the installation version. The source code version is prone to error prompts. The 32 and 64 versions are packaged below.MySQL-python-1.2.3.win32-py2.7.exeMySQL-python-1.2.3.win-amd64-py2.7.exe
The installation process is simple:Instance 1. Obtain the MYSQL version
#-*-Coding: UTF-8-*-# Install mysql db for pythonimport MySQLdb as mdbcon =
个字符串用于存储连接数据库字符串 string s = "server=localhost;database=hasion;uid=sa;pwd=hasion"; SqlConnection con = new SqlConnection(s); con.Open();The connection to the database is turned on.2. Command: When an application establishes a connection to a data source, the command object is required to execute commands and return results from the data source. It is a data command object, the main function is to send queries to the database, updat
SqlConnection con = new SqlConnection (conn_string); Try { Open a connection, execute a query and return to SqlDataReader Con. Open (); SqlCommand cmd = con. CreateCommand (); Cmd.commandtext = SQL; SqlDataReader dr = cmd. ExecuteReader (); Return Dr; } Finally { The code here is in a dilemma. If this is done close: con
Dbconnectionpool is described in detail as follows:
I. Construction of Dbconnectionpool
constructor to obtain all of the above parameters:
Public Dbconnectionpool (string name, string URL, String user,
String password, int maxconn) {
THIS.name = name;
This. url = URL;
This.user = user;
This.password = password;
This.maxconn = Maxconn;
}
Save all parameters in the instance variable.
Second, open a connection from the pool
Dbconnectionpool provides two ways to chec
specifications mentioned above.
// Context (Environment) role, which uses hashmap to store the value corresponding to the variableClass Context{Private map valuemap = new hashmap ();Public void addvalue (variable X, int y){Integer YI = new INTEGER (y );Valuemap. Put (x, Yi );}Public int lookupvalue (variable X){Int I = (integer) valuemap. Get (x). intvalue ();Return I;}}// Abstract expression role, which can also be implemented using interfacesAbstract class expression{Public abstract
Detailed descriptions of four functions of mysql_result mysql_fetch_row mysql_fetch_array mysql_fetch_object in php
Mysql tutorial _ result (): The advantage lies in ease of use; its disadvantage is that there are few functions. One call can only obtain one row of elements in the result dataset, which is less efficient for large-scale database tutorials;
The value of a field in the returned result set returned by the mysql_result () function.
If successful, the function returns the field value.
database.Using system. Data. oledb;
/// /// This is mainly the database connection class used in the message book. because there are not many data operations, the conventional operation classes are also put here./// Public class ODB{Public string name;Public String email;Public String QQ;Public String MSN;Public String URL;Public String title;Public String concent;Public String face;Public String IP;Public String PWD;Public String uid;Public String pwda;Public datetime DTT;Public ODB (){//// T
is mainly the database connection class used in the message book. because there are not many data operations, the conventional operation classes are also put here./// Public class odb{Public string name;Public string email;Public string qq;Public string msn;Public string url;Public string title;Public string concent;Public string face;Public string ip;Public string pwd;Public string uid;Public string pwda;Public DateTime dtt;Public odb (){//// TODO: add the constructor logic here//}Public stati
ADO. NET provides connection to connect to the database and command object to query the database. Like the connection object, there are two types of commands: oledbcommand and sqlcommand. The difference is the same as that of the connection object.
To manipulate the database, you must first use connection to connect to the database, and then create a command to query. There are several creation methods, for example:
Sqlcommand cmd;
String strcon = "Server = localhost; database = northwind; trust
The details are as follows:To allow PHP to execute the preceding statement, we must use the mysql_query () function. This function is used to send queries or commands to MySQL connections.ExampleIn the following example, we created a database named "my_db: The code is as follows:Copy code $ Con = mysql_connect ("localhost", "peter", "abc123 ");If (! $ Con){Die ('co
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.