Python Code Samples



Filters


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

from mysql import connector
python mysql mysql-connector
gaya38
Generate Random number within the range in python
gaya38 | 8 years
import random
print random.uniform(10,500)
python
sandeep
Shell Script to Generate the SSH key and display it on output screen also create virtualenv
sandeep | 8 years, 3 months
export PATH=$WORKSPACE/resources/chromedriver/mac:$WORKSPACE/venv/bin:/usr/local/bin:$PATH
export P
shell auto ssh key
Connect to mongo db using python and list of databases
kishore_kumar | 7 years, 6 months
import pymongo

client = pymongo.MongoClient("mongodb://localhost:27017")
pymongo python mongodb
Ramya
PYTHON: To download AWS ELB access log files from S3 bucket based on last modified time
Ramya | 6 years, 7 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 os details using python os
kishore_kumar | 8 years, 3 months
import os
print os.uname()
# Don't use os.system('uname -a'), its just executing "uname -a" comman
python python-os
How to connect to PostgreSQL database and display list of tables in python
kishore_kumar | 7 years, 6 months
import psycopg2

conn = psycopg2.connect(host="localhost", database="mydb", user="kishore", passwo
python psycopg2 postgresql
fetch all documents from mongo db collection using python
kishore_kumar | 7 years, 6 months
import pymongo

client = pymongo.MongoClient("mongodb://localhost:27017")
pymongo python mongodb
json string to python dictionary using json module
kishore_kumar | 7 years, 10 months
import json

my_str = '{"1": 4, "4": 2, "5":3 }'
python json
Ramya
Difference between normal def defined function and lambda function in Python
Ramya | 7 years, 2 months
li = [4,65,65,23,86,343,75,3,7,5,87,34,56,64,90] 
final_list = list(filter(lambda x: (x%2 == 0) , l
lambda python
Prev Next