File: pymongo.3

package info (click to toggle)
pymongo 4.10.1-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 19,928 kB
  • sloc: python: 91,879; ansic: 4,537; javascript: 137; sh: 32; makefile: 31
file content (58 lines) | stat: -rw-r--r-- 1,398 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
.TH PYMONGO 3 "March 13, 2010"
.SH NAME
pymongo \- Python interface for MongoDB
.SH SYNOPSIS
.B pymongo
.br
.SH DESCRIPTION
.br
This manual page documents briefly the
.B pymongo
python library.
.PP
.SH USAGE
Assuming that a running instance of MongoDB is available, setup a connection to the daemon:

>>> from pymongo import Connection
.br
>>> connection = Connection('localhost', 27017)

If you are happy with the default values (localhost) you can simply use Connection()
.br
A single instance of MongoDB can support multiple independent databases.

Select the database you want to use: 

>>> db = connection.test_database

You can use dictionary-style access instead:

>>> db = connection['test-database']

A collection is a group of documents stored in MongoDB, a bit like a table in a relational database.
.br
Get a collection:

>>> collection = db.test_collection
.br
Or:
.br
>>> collection = db['test-collection']

Warning: Collections and databases are created when the first document is inserted into them.
.br
Example of data insertion:

>>> item = {"author": "Me","title": "This is a test"}
>>> collection.insert(item)

Comprehensive documentation can be found at:
.br
http://api.mongodb.org/python/

.br
.SH AUTHOR
pymongo was written by Mike Dirolf.
.PP
This manual page was written by Federico Ceratto <federico.ceratto@gmail.com>,
for the Debian project (and may be used by others).