0% found this document useful (0 votes)
26 views6 pages

Finalproject 1 1

The document creates tables in a database to store stock market data. The nse table stores company stock data like name, opening price, and closing price. The nseper table stores company category data by name. Python code is then provided to query the database tables to return company details and analyze if the stock was bullish or bearish based on closing price compared to opening price.

Uploaded by

vaidehi7206
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views6 pages

Finalproject 1 1

The document creates tables in a database to store stock market data. The nse table stores company stock data like name, opening price, and closing price. The nseper table stores company category data by name. Python code is then provided to query the database tables to return company details and analyze if the stock was bullish or bearish based on closing price compared to opening price.

Uploaded by

vaidehi7206
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

1)

create table nse

(ENo integer,

Name varchar(40),

OpeningPrice float,

ClosingPrice float);

2)

insert into nse values(1,'Network 18 Media and Invesments',79.64,78.75);

3)

insert into nse values(2,'Tata Power',254.45 ,255.9);

4)

insert into nse values(3,'LIC',636 ,639);

5)

insert into nse values(4,'NTPC',240.05 ,238.95);

6)

insert into nse values(5,'ITI',180.00 ,175.50);

7)

insert into nse values(6,'Infosys',1430.25,1445.25);


8)

insert into nse values(7,'Tata Steel' , 129.12,130.63);

9)

insert into nse values(8,'TCS',244.88,249.74);

10)

insert into nse values(9,'Wipro',240.05,238.95);

11)

insert into nse values(10,'Maruti',175.00 ,190.85);

12)

insert into nsevalues(11,'Hero Motocorp',295.64,300.83);

13)

insert into nse values(12,'Reliance',129.36 ,131.27);

14)

insert into nse values(13,'Adani',243.38,246.99);

table: nseper
create table nseper

( Name varchar(40) references nse(Name) on update cascade on delete cascade,

Category varchar(40));

insert into nseper values('Adani', ' Manufacturing');

insert into nseper values('Infosys', 'Information Technology and Services');

insert into nseper values('Hero Motocorp', 'Automotive ');

insert into nseper values('Reliance', 'Industry ');

insert into nseper values('Tata Steel', 'Manufacturing ');

insert into nseper values('Maruti', 'Automotive ');

insert into nseper values('TCS', 'Information Technology and Services');

insert into nseper values('LIC', 'Financial Services');

insert into nseper values('Wipro', 'Information Technology and Services');

insert into nseper values('Tata Power', 'Power and Energy');

insert into nseper values('Network 18 Media and Investments', 'Media Entertainment and Publications');

insert into nseper values('ITI', 'Telecom');

insert into nseper values('NTPC', 'Power and Energy');


PYTHON

def company():

c=input('enter name of the company')

st="select nse.name,closingprice, opening price, from nse, nseper where nse.name=nseper.name and nse.name='%s';"%c

return st

def category():

cat=input('Category')

st="select nse.name,openingprice,closingprice from nse,nseper where nse.name=nseper.name and category='%cat';" %cat

return st

import mysql.connector as sqltor

nsecon=sqltor.connect(host='localhost', user='root',password='vaids@0123',database='project')

nsecur=nsecon.cursor()

print('Intro to Project: NSE')

ch=input('enter c for company and b for bullbear and cat for category')

if ch.upper()=='C':

st=company()

nsecur.execute(st)

data=nsecur.fetchall()

for row in data:

print('Details of the company are as follows: NAME , CLOSING PRICE, CHANGES, BULLBEAR')

print(row[0],row[1],row[1]-row[2],end=' ')

if row[1]>row[2]:

print('BULLISH')
else:

print('BEARISH')

if ch.upper()=='B':

st=bullbear()

nsecur.execute(st)

data=nsecur.fetchall()

print('Details of the company are as follows: NAME , CLOSING PRICE, CHANGES')

for row in data:

print(row[0],row[1],row[1]-row[2], end=' ')

if row[1]>row[2]:

print('BULLISH')

else:

print('BEARISH')

elif ch.upper()=='CAT':

st=category()

nsecur.execute(st)

data=nsecur.fetchall()

for row in data:

print(row)

nsecon.close()

You might also like