Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions database/createdb.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import pymysql

# Open database connection
db = pymysql.connect("localhost","root","admin","py_work" )

# prepare a cursor object using cursor() method
cursor = db.cursor()

# Drop table if it already exist using execute() method.
cursor.execute("DROP TABLE IF EXISTS EMPLOYEE")

# Create table as per requirement
sql = """CREATE TABLE NEWDATA (
FIRST_NAME CHAR(20) NOT NULL,
LAST_NAME CHAR(20),
AGE INT,
SEX CHAR(1),
INCOME FLOAT )"""

cursor.execute(sql)

# disconnect from server
db.close()
7 changes: 7 additions & 0 deletions database/mysql.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import pymysql
connection = pymysql.connect(host='localhost',user='root',passwd='admin',db='py_work')
cursor=connection.cursor()
sql=('select * from Persons')
cursor.execute(sql)
data=cursor.fetchall()
print(data)
4 changes: 4 additions & 0 deletions files/New folder/copy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
with open('text.txt','r')as rf:
with open('test_copy.txt','w')as wf:
for line in rf:
wf.write(line)
9 changes: 9 additions & 0 deletions files/New folder/open.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
f = open("text.txt","r")

t=f.read()

print(t)
f.close()



1 change: 1 addition & 0 deletions files/New folder/test2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
relcome
1 change: 1 addition & 0 deletions files/New folder/text.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hi this is vasanth!!
6 changes: 6 additions & 0 deletions files/New folder/write.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
with open('test2.txt','w')as f:
f.write('Welcome')
#f.seek(0)
#f.write('r')
f.write('Welcome')

4 changes: 4 additions & 0 deletions files/read.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
file = open("C:\\Users\\vasan\\OneDrive\\Desktop\\test.txt","r")
for line in file:
x = line.split(",")
print(x[0],'\t',x[2])
3 changes: 3 additions & 0 deletions files/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Hi !!, how are you, nice to meet you
Hello World!!,python programming, really
This is Vasanth Nagarajan !!!,file operations, move
7 changes: 7 additions & 0 deletions functions/fucntion2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This is theanother progrma for the function defining the name

def hello(name):
print('Hello '+ name)

hello('vasanth')
hello('nagarajan')
11 changes: 11 additions & 0 deletions functions/hellofunction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This is the simplest program to create a function


def hello():
print('Hello World!')
print('Hello world!!')
print('Hello World@@@@')

hello()
hello()
hello()
4 changes: 4 additions & 0 deletions functions/ran.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import random

for i in range(5):
print(random.randint(1,50))
6 changes: 6 additions & 0 deletions functions/random.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# This program is about Random variable

import random

for i in range(10):
print(random.randint(1,10))
22 changes: 22 additions & 0 deletions inheritance/parentclass.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Parent:
def __init__(self):
print("This is the parent class")
def parentFunc(self):
print("This is the parent func")

p = Parent()
p.parentFunc()


#Child Class
class Child(Parent):
def __init__(self):
print("This is the Child Class")
def childFunc(self):
print("This is the Child func")
c = Child()
c.childFunc()

#Child calls the parent function
c.parentFunc()

54 changes: 54 additions & 0 deletions myname.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#print the last letter from myname

myname = input("Enter you name:")
#print(myname[-1])
'''
print(myname[0])
print(myname[1])
print(myname[2])
print(myname[3])
print(myname[4])
'''
#Method1
#LIST
newarray = []
oddcount = 0
evencount = 0
for i in range(len(myname)):
print (myname[i])
newarray.append(i)
newarray.append(myname[i])


print ("New Array from Myname..",newarray)
result = 0
for i in newarray:
if type(i) == int:
result = result + i
print("SUM of interger numbers from Array..",result)
#ODDEVEN
for i in range(len(newarray)):
if i % 2 == 0:
evencount = evencount + 1
else:
oddcount = oddcount + 1
print ("ODD position values",evencount)
print ("Even Position values",oddcount)
#Tuple
tuplearray = []
#expected output = [(0,'K'),(1,'G')]
for i in range(len(myname)):
tuplearray.append((i,myname[i]))

print("New tuple from myname",tuplearray)
#dictionary
newdict = {}
for i in range(len(myname)):
newdict[i] = myname[i]
print("New dict from myname",newdict)
print (newdict[0])
'''
#mentod2
for i in myname:
print (i)
'''
Binary file added python with access/Database1.accdb
Binary file not shown.
11 changes: 11 additions & 0 deletions python with access/con2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pypyodbc

# Create Connection
con = pypyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};UID=admin;UserCommitSync=Yes;Threads=3;SafeTransactions=0;PageTimeout=5;MaxScanRows=8;;MaxBufferSize=2048FIL={MS Access};DriverId=25;DefaultDir=C:/Users/vasan/OneDrive/Documents;DBQ=C:/Users/vasan/OneDrive/Documents/Database2.mdb;')

cursor = con.cursor()

cursor.execute("SELECT * FROM details")

for row in cursor.fetchall():
print(row)
11 changes: 11 additions & 0 deletions python with access/connn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import pypyodbc

# Create Connection
con = pypyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};UID=admin;UserCommitSync=Yes;Threads=3;SafeTransactions=0;PageTimeout=5;MaxScanRows=8;;MaxBufferSize=2048FIL={MS Access};DriverId=25;DefaultDir=C:/Users/vasan/OneDrive/Documents;DBQ=C:/Users/vasan/OneDrive/Documents/Database1.mdb;')

cursor = con.cursor()

cursor.execute("SELECT * FROM contacts")

for row in cursor.fetchall():
print(row)
14 changes: 14 additions & 0 deletions python with access/ms access package.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pip install pyodbc
pip install pypyodbc

import pypyodbc

# Create Connection
con = pypyodbc.connect('DRIVER={Microsoft Access Driver (*.mdb)};UID=admin;UserCommitSync=Yes;Threads=3;SafeTransactions=0;PageTimeout=5;MaxScanRows=8;;MaxBufferSize=2048FIL={MS Access};DriverId=25;DefaultDir=C:/Users/vasan/OneDrive/Documents;DBQ=C:/Users/vasan/OneDrive/Documents/Database2.mdb;')

cursor = con.cursor()

cursor.execute("SELECT * FROM contacts")

for row in cursor.fetchall():
print(row)