Skip to content

benjamintenny/mongo-python-driver-proxy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongo-python-driver-proxy

PyMongo proxy - http/socks proxy support with python-socks.

About

This repo forked from Pymongo official repo for http/socks proxy support with the help of python-socks. DNS resolving done by pymongo itself. Connection done by python-socks. For more information please refer to Pymongo and about proxies refer to python-socks.

How to install

If you installed pymongo before you need to remove it first:

pip uninstall pymongo

Install it with git:

pip install git+https://github.com/benjamintenny/mongo-python-driver-proxy

You can also download the project source and then install it with pip:

pip install .

Examples

Here's a basic example about using pymongo with proxies:

import os
import pymongo
# Set socks5 proxy
os.environ["MONGO_PROXY"] = "socks5://127.0.0.1:1080"
# Connect to db as normal
client = pymongo.MongoClient("your-mongodb-url")
db = client.test
print(db.name)

Also you can:

Socks5 with authentication:

os.environ["MONGO_PROXY"] = "socks5://username:[email protected]:1080"

HTTP proxy with authentication:

os.environ["MONGO_PROXY"] = "http://username:[email protected]:8080"

Socks4 proxy:

os.environ["MONGO_PROXY"] = "socks4://127.0.0.1:1080"

About

PyMongo with proxy support

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 96.2%
  • C 3.0%
  • Other 0.8%