Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
kl_task4_1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
arun.uday
kl_task4_1
Commits
193c06c4
Commit
193c06c4
authored
Jan 30, 2023
by
arun.uday
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
v3
parent
40b0b545
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
45 additions
and
5 deletions
+45
-5
.idea/modules.xml
+2
-1
.idea/sonarlint/issuestore/index.pb
+18
-0
.idea/task4.1_mongo_post.iml
+0
-0
app.py
+3
-2
scripts/core/handlers/view_data_db.py
+10
-0
scripts/services/access_functions.py
+3
-1
scripts/services/mongo_db_operations.py
+9
-1
No files found.
.idea/modules.xml
View file @
193c06c4
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<project
version=
"4"
>
<project
version=
"4"
>
<component
name=
"ProjectModuleManager"
>
<component
name=
"ProjectModuleManager"
>
<modules>
<modules>
<module
fileurl=
"file://$PROJECT_DIR$/.idea/task4.1
.iml"
filepath=
"$PROJECT_DIR$/.idea/task4.1
.iml"
/>
<module
fileurl=
"file://$PROJECT_DIR$/.idea/task4.1
_mongo_post.iml"
filepath=
"$PROJECT_DIR$/.idea/task4.1_mongo_post
.iml"
/>
</modules>
</modules>
</component>
</component>
</project>
</project>
\ No newline at end of file
.idea/sonarlint/issuestore/index.pb
View file @
193c06c4
No preview for this file type
.idea/task4.1.iml
→
.idea/task4.1
_mongo_post
.iml
View file @
193c06c4
File moved
app.py
View file @
193c06c4
# main application for database task
# main application for database task
from
scripts.core.engine.postgres_connect
import
cur
,
postgres_client
from
scripts.services.access_functions
import
mongo_db_access_op
,
postgres_db_access_op
from
scripts.services.access_functions
import
mongo_db_access_op
,
postgres_db_access_op
# mongodb
# mongodb
...
@@ -7,11 +6,13 @@ db_choice = input("Enter mongo or postgres")
...
@@ -7,11 +6,13 @@ db_choice = input("Enter mongo or postgres")
if
db_choice
==
'mongo'
:
if
db_choice
==
'mongo'
:
print
(
"Mongo DB"
)
print
(
"Mongo DB"
)
mongo_db_access_op
()
mongo_db_access_op
()
el
se
:
el
if
db_choice
==
'postgres'
:
print
(
"PostgresSQL"
)
print
(
"PostgresSQL"
)
result
=
postgres_db_access_op
()
result
=
postgres_db_access_op
()
if
not
result
:
if
not
result
:
print
(
"Lost in atoms"
)
print
(
"Lost in atoms"
)
else
:
else
:
print
(
"Successful"
)
print
(
"Successful"
)
else
:
print
(
"Lost in atoms"
)
scripts/core/handlers/view_data_db.py
View file @
193c06c4
...
@@ -22,3 +22,13 @@ def view_fields(db, field_filter, data_find):
...
@@ -22,3 +22,13 @@ def view_fields(db, field_filter, data_find):
print
(
view_data
)
print
(
view_data
)
else
:
else
:
print
(
"Data fetching failed"
)
print
(
"Data fetching failed"
)
def
view_all
(
db
):
view_data_cursor
=
db
.
find
({},
{
'_id'
:
0
})
if
len
(
list
(
view_data_cursor
.
clone
()))
>
0
:
print
(
"Data collected...."
)
view_data
=
pd
.
json_normalize
((
view_data_record
for
view_data_record
in
view_data_cursor
))
print
(
view_data
)
else
:
print
(
"Data fetching failed"
)
scripts/services/access_functions.py
View file @
193c06c4
...
@@ -9,7 +9,7 @@ def mongo_db_access_op():
...
@@ -9,7 +9,7 @@ def mongo_db_access_op():
db_created
=
db_class
.
mongo_create
()
db_created
=
db_class
.
mongo_create
()
while
True
:
while
True
:
try
:
try
:
user_query
=
input
(
"Enter insert/ update/ delete/ view/ quit : "
)
user_query
=
input
(
"Enter insert/ update/ delete/ view/
view-all/
quit : "
)
if
user_query
==
'insert'
:
if
user_query
==
'insert'
:
db_class
.
mongo_insert
(
db_created
)
db_class
.
mongo_insert
(
db_created
)
elif
user_query
==
'update'
:
elif
user_query
==
'update'
:
...
@@ -18,6 +18,8 @@ def mongo_db_access_op():
...
@@ -18,6 +18,8 @@ def mongo_db_access_op():
db_class
.
mongo_delete
(
db_created
)
db_class
.
mongo_delete
(
db_created
)
elif
user_query
==
'view'
:
elif
user_query
==
'view'
:
db_class
.
mongo_view
(
db_created
)
db_class
.
mongo_view
(
db_created
)
elif
user_query
==
'view-all'
:
db_class
.
mongo_view_all
(
db_created
)
else
:
else
:
print
(
"Exiting...."
)
print
(
"Exiting...."
)
break
break
...
...
scripts/services/mongo_db_operations.py
View file @
193c06c4
...
@@ -4,7 +4,7 @@ from scripts.core.engine.mongodb_connect import client
...
@@ -4,7 +4,7 @@ from scripts.core.engine.mongodb_connect import client
from
scripts.core.handlers.data_insert
import
insert_data_db
,
read_inputs
from
scripts.core.handlers.data_insert
import
insert_data_db
,
read_inputs
from
scripts.core.handlers.delete_db_data
import
delete_db_input
,
db_delete
from
scripts.core.handlers.delete_db_data
import
delete_db_input
,
db_delete
from
scripts.core.handlers.update_mongo_db
import
db_update
,
input_update_db
from
scripts.core.handlers.update_mongo_db
import
db_update
,
input_update_db
from
scripts.core.handlers.view_data_db
import
view_fields
,
view_cond
from
scripts.core.handlers.view_data_db
import
view_fields
,
view_cond
,
view_all
class
MongoDbStart
:
class
MongoDbStart
:
...
@@ -74,4 +74,12 @@ class MongoDbStart:
...
@@ -74,4 +74,12 @@ class MongoDbStart:
except
Exception
as
e
:
except
Exception
as
e
:
print
(
f
'{exception_msg}{e}'
)
print
(
f
'{exception_msg}{e}'
)
@staticmethod
def
mongo_view_all
(
db
):
try
:
view_all
(
db
)
except
Exception
as
e
:
print
(
f
'{exception_msg}{e}'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment