Python Code Samples



Filters


Connect to PostgreSQL in c# applications using Npgsql
harika | 4 years, 9 months
using System.Text;
using System.Threading.Tasks;
using IronPython.Hosting;
By default PostgreSql installed on 5432 port. If you have already configured the port while installi
c# csharp postgresql
Matrix transpose using list comprehensions in python
harika | 5 years, 2 months
a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
#Procedure1:--------
transposed = [[row[i] for row in a ] fo
List comprehensions in python basically reduce the loc. Check the difference between two procudures
python matrix list
gaya38
Generate Random number within the range in python
gaya38 | 5 years, 7 months
import random
print random.uniform(10,500)
python
Get os details using python os
kishore_kumar | 5 years, 9 months
import os
print os.uname()
# Don't use os.system('uname -a'), its just executing "uname -a" comman
python python-os
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
sandeep
Shell Script to Generate the SSH key and display it on output screen also create virtualenv
sandeep | 5 years, 10 months
export PATH=$WORKSPACE/resources/chromedriver/mac:$WORKSPACE/venv/bin:/usr/local/bin:$PATH
export P
shell auto ssh key
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, 9 months
import os
env = os.environ

python python-os
Prev Next