Python Code Samples



Filters


Connect to MySQL database with python mysql connector
kishore_kumar | 5 years
# pip install mysql-connector

from mysql import connector
python mysql mysql-connector
Connect to mongo db using python and list of databases
kishore_kumar | 5 years, 1 month
import pymongo

client = pymongo.MongoClient("mongodb://localhost:27017")
pymongo python mongodb
Ramya
PYTHON: AWS IAM password reset
Ramya | 4 years, 1 month
import boto3
client = boto3.client('iam')
UserName=input("Enter UserName:")
boto3 python
Ramya
PYTHON: To download AWS ELB access log files from S3 bucket based on last modified time
Ramya | 4 years, 2 months
import boto3
import datetime
from datetime import datetime,timedelta,date
Before using this script, you need to set up AWS CLI first as below: ubuntu@ip-172-31-46-2:~$ aws
python boto3 s3
Get current environment variables in python
kishore_kumar | 5 years, 10 months
import os
env = os.environ

python python-os
sandeep
Python Script to create AWS beanstalk
sandeep | 5 years, 10 months
#!/usr/bin/python
  
import boto
python aws beanstalk
fetch all documents from mongo db collection using python
kishore_kumar | 5 years, 1 month
import pymongo

client = pymongo.MongoClient("mongodb://localhost:27017")
pymongo python mongodb
gaya38
Shuffle list elements in python
gaya38 | 5 years, 7 months
import random;
z = [1,90,4,2]
z = random.shuffle(z)
python
Usage of Operator functions instead of lambda functions
harika | 5 years, 2 months
import functools
import operator
list = [1, 2, 3, 4, 5]
Both lines generates the same result
lambda operator python
json string to python dictionary using json module
kishore_kumar | 5 years, 5 months
import json

my_str = '{"1": 4, "4": 2, "5":3 }'
python json
Prev Next