Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 00e77e6

Browse files
making a connection
1 parent 08f2a3e commit 00e77e6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

‎README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,24 @@ MongoDB with Pymongo Tutorial
77
$ pip install pymongo
88
```
99

10+
### Making a Connection
11+
12+
Making a connection without authentication:
13+
14+
```
15+
>>> from pymongo import MongoClient
16+
>>> uri = 'mongodb://mongodb.domain.com:27017/'
17+
>>> client = MongoClient(uri)
18+
>>> client.database_names()
19+
[u'admin', u'local', u'mycargarage', u'random_api', u'shared_db', u'testdb']
20+
```
21+
22+
Making a connection with authentication:
23+
24+
```
25+
>>> from pymongo import MongoClient
26+
>>> uri = 'mongodb://username:password@mongodb.domain.com:27017/random_api?authSource=admin&authMechanism=SCRAM-SHA-1'
27+
>>> client = MongoClient(uri)
28+
>>> client.database_names()
29+
[u'admin', u'local', u'mycargarage', u'random_api', u'shared_db', u'testdb']
30+
```

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /