@@ -125,27 +125,27 @@ We haven't even begun to touch upon all the parameters ``connect()``
125
125
can take. For this reason, I prefer to use keyword parameters::
126
126
127
127
db=_mysql.connect(host="localhost",user="joebob",
128
- passwd ="moonpie",db ="thangs")
128
+ password ="moonpie",database ="thangs")
129
129
130
130
This does exactly what the last example did, but is arguably easier to
131
131
read. But since the default host is "localhost", and if your login
132
132
name really was "joebob", you could shorten it to this::
133
133
134
- db=_mysql.connect(passwd ="moonpie",db ="thangs")
134
+ db=_mysql.connect(password ="moonpie",database ="thangs")
135
135
136
136
UNIX sockets and named pipes don't work over a network, so if you
137
137
specify a host other than localhost, TCP will be used, and you can
138
138
specify an odd port if you need to (the default port is 3306)::
139
139
140
- db=_mysql.connect(host="outhouse",port=3307,passwd ="moonpie",db ="thangs")
140
+ db=_mysql.connect(host="outhouse",port=3307,password ="moonpie",database ="thangs")
141
141
142
142
If you really had to, you could connect to the local host with TCP by
143
143
specifying the full host name, or 127.0.0.1.
144
144
145
145
Generally speaking, putting passwords in your code is not such a good
146
146
idea::
147
147
148
- db=_mysql.connect(host="outhouse",db ="thangs",read_default_file="~/.my.cnf")
148
+ db=_mysql.connect(host="outhouse",database ="thangs",read_default_file="~/.my.cnf")
149
149
150
150
This does what the previous example does, but gets the username and
151
151
password and other parameters from ~/.my.cnf (UNIX-like systems). Read
@@ -561,7 +561,7 @@ Some examples
561
561
The ``connect() `` method works nearly the same as with `MySQLDB._mysql `_::
562
562
563
563
import MySQLdb
564
- db=MySQLdb.connect(passwd ="moonpie",db ="thangs")
564
+ db=MySQLdb.connect(password ="moonpie",database ="thangs")
565
565
566
566
To perform a query, you first need a cursor, and then you can execute
567
567
queries on it::
0 commit comments