forked from EndPrep/endprep
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopulate_database.py
More file actions
134 lines (105 loc) · 5.43 KB
/
populate_database.py
File metadata and controls
134 lines (105 loc) · 5.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from models import *
engine = create_engine(
'postgresql://octauser:dynamic*_*website@localhost/octa')
Base.metadata.bind = engine
DBSession = sessionmaker(bind=engine)
session = DBSession()
newUser = User(name='Shruti Sheoran', email="shruti.sheoran03@gmail.com",
picture="", rating=0)
session.add(newUser)
session.commit()
newSubject = Subject(name='Computer Networks', picture='https://fthmb.tqn.com/XdZgKpmI19Clz49VkA2d_SCAafY=/768x0/filters:no_upscale():max_bytes(150000):strip_icc()/computer-network-alex-slobodkin-e-plus-getty-images-56a6fab03df78cf772913eff.jpg') # noqa
session.add(newSubject)
session.commit()
newChapter = Chapter(title='DATA COMMUNICATIONS', about='''When we communicate,
we are sharing information. This sharing can be local or remote. Between
individuals, local communication usually occurs face to face, while remote
communication takes place over distance. The term telecommunication, which
includes telephony, telegraphy, and television, means communication at a
distance (tele is Greek for "far").''', subject=newSubject)
session.add(newChapter)
session.commit()
newChapter = Chapter(title='Networks', about='''A network is a set of
devices (often referred to as nodes) connected by communication links. A node
can be a computer, printer, or any other device capable of sending and/or
receiving data generated by other nodes on the network.''', subject=newSubject)
session.add(newChapter)
session.commit()
newSubject = Subject(name='Operating Systems',
picture='https://www.computerhope.com/issues/pictures/operating-system-install.jpg')
session.add(newSubject)
session.commit()
newChapter = Chapter(title='Overview', about='''An Operating System (OS) is
an interface between a computer user and computer hardware. An operating
system is a software which performs all the basic tasks like file management,
memory management, process management, handling input and output, and
controlling peripheral devices such as disk drives and printers.
Some popular Operating Systems include Linux, Windows, OS X, VMS, OS/400, AIX,
z/OS, etc.''', subject=newSubject)
session.add(newChapter)
session.commit()
newChapter = Chapter(title='Security', about='''Security refers to
providing a protection system to computer system resources such as CPU,
memory, disk, software programs and most importantly data/information
stored in the computer system. If a computer program is run by an unauthorized
user, then he/she may cause severe damage to computer or data stored in it.
So a computer system must be protected against unauthorized access, malicious
access to system memory, viruses, worms etc.''', subject=newSubject)
session.add(newChapter)
session.commit()
newSubject = Subject(name='Computer Architecture', picture='https://www.edx.org/sites/default/files/course/image/promoted/mitx_6.004.2x_378x225.jpg') # noqa
session.add(newSubject)
session.commit()
newChapter = Chapter(title='Introduction', about='', subject=newSubject)
session.add(newChapter)
session.commit()
newChapter = Chapter(title='Getting Started', about='', subject=newSubject)
session.add(newChapter)
session.commit()
newSubject = Subject(
name='C++', picture='http://res.cloudinary.com/mftgilancom/image/upload/v1494491628/ICT-DPT/c--logo-icon-0_tijqtg.png')
session.add(newSubject)
session.commit()
newChapter = Chapter(title='Functions', about='''A function is a group
of statements that together perform a task. Every C++ program has at least
one function, which is main(), and all the most trivial programs can define
additional functions.''', subject=newSubject)
session.add(newChapter)
session.commit()
newChapter = Chapter(title='Pointers', about='''C++ pointers are easy and
fun to learn. Some C++ tasks are performed more easily with pointers, and other
C++ tasks, such as dynamic memory allocation, cannot be performed without
them.''', subject=newSubject)
session.add(newChapter)
session.commit()
newSubject = Subject(name='Digital Electronics',
picture='http://www.wilsontande.net/images/debanner.png')
session.add(newSubject)
session.commit()
newChapter = Chapter(title='What are Digital Computers?', about='''The
digital computer is a digital system that performs various computational tasks.
The word digital implies that the information in the computer is represented
by variables that take a limited number of discrete values. These values are
processed internally by components that can maintain a limited number of
discrete states.''', subject=newSubject)
session.add(newChapter)
session.commit()
newChapter = Chapter(title='Memory Unit', about='''A Memory Unit is a
collection of storage cells together with associated circuits needed to
transfer information in and out of storage.''', subject=newSubject)
session.add(newChapter)
session.commit()
newSubject = Subject(
name='Python', picture='https://cdn-images-1.medium.com/max/1200/1*PPIp7twJJUknfohZqtL8pQ.png')
session.add(newSubject)
session.commit()
newChapter = Chapter(title='Python 3 Overview', about='''Python is a
high-level, interpreted, interactive and object-oriented scripting language.
Python is designed to be highly readable. It uses English keywords frequently
whereas the other languages use punctuations. It has fewer syntactical
constructions than other languages.''', subject=newSubject)
session.add(newChapter)
session.commit()
print "Added items!"