Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
postgresql
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ramya.r
postgresql
Commits
91d82bdc
Commit
91d82bdc
authored
Mar 27, 2023
by
ramya.r
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated
parent
9bb875b7
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
87 additions
and
34 deletions
+87
-34
.idea/sonarlint/issuestore/6/6/667b853e3f9ccfca10dbccfd60360189bb0c13c0
...t/issuestore/6/6/667b853e3f9ccfca10dbccfd60360189bb0c13c0
+0
-0
.idea/sonarlint/issuestore/index.pb
.idea/sonarlint/issuestore/index.pb
+14
-2
.idea/sonarlint/securityhotspotstore/6/6/667b853e3f9ccfca10dbccfd60360189bb0c13c0
...hotspotstore/6/6/667b853e3f9ccfca10dbccfd60360189bb0c13c0
+0
-0
.idea/sonarlint/securityhotspotstore/index.pb
.idea/sonarlint/securityhotspotstore/index.pb
+14
-2
.idea/vcs.xml
.idea/vcs.xml
+6
-0
script/core/handlers/postgresql.py
script/core/handlers/postgresql.py
+16
-29
script/service/postgres.py
script/service/postgres.py
+1
-1
script/utils/postgresql_utils.py
script/utils/postgresql_utils.py
+36
-0
No files found.
.idea/sonarlint/issuestore/6/6/667b853e3f9ccfca10dbccfd60360189bb0c13c0
deleted
100644 → 0
View file @
9bb875b7
.idea/sonarlint/issuestore/index.pb
View file @
91d82bdc
A
posgresql_file.py,6\6\667b853e3f9ccfca10dbccfd60360189bb0c13c0
\ No newline at end of file
w
G.idea/sonarlint/issuestore/6/6/667b853e3f9ccfca10dbccfd60360189bb0c13c0,b\f\bf9cbfde56e63e25f2e8fc503c6b0f7405899a60
Q.idea/sonarlint/securityhotspotstore/6/6/667b853e3f9ccfca10dbccfd60360189bb0c13c0,3\d\3d30efdcf9bca3bb39e6c670f6e549ad72ca7f30
^
..idea/inspectionProfiles/profiles_settings.xml,1\e\1e9075f5bf079c01ef2c910709e91a497d262080
N
script/core/schema/__init__.py,8\4\84b7e789bb411a2f2e44fa4f79362bae15a9ca5e
E
conf/application.conf,6\4\644f59db746795ef1538ef95c4cbc0eab6663e28
P
script/core/schema/postgresql.py,1\9\19f52c691d887de665bc4147a5e3b407badd4cf7
K
script/config/app_config.py,e\7\e7a8f69b82d0d0839cd67ff968caeb054957923f
\ No newline at end of file
.idea/sonarlint/securityhotspotstore/6/6/667b853e3f9ccfca10dbccfd60360189bb0c13c0
deleted
100644 → 0
View file @
9bb875b7
.idea/sonarlint/securityhotspotstore/index.pb
View file @
91d82bdc
A
posgresql_file.py,6\6\667b853e3f9ccfca10dbccfd60360189bb0c13c0
\ No newline at end of file
w
G.idea/sonarlint/issuestore/6/6/667b853e3f9ccfca10dbccfd60360189bb0c13c0,b\f\bf9cbfde56e63e25f2e8fc503c6b0f7405899a60
Q.idea/sonarlint/securityhotspotstore/6/6/667b853e3f9ccfca10dbccfd60360189bb0c13c0,3\d\3d30efdcf9bca3bb39e6c670f6e549ad72ca7f30
^
..idea/inspectionProfiles/profiles_settings.xml,1\e\1e9075f5bf079c01ef2c910709e91a497d262080
N
script/core/schema/__init__.py,8\4\84b7e789bb411a2f2e44fa4f79362bae15a9ca5e
E
conf/application.conf,6\4\644f59db746795ef1538ef95c4cbc0eab6663e28
P
script/core/schema/postgresql.py,1\9\19f52c691d887de665bc4147a5e3b407badd4cf7
K
script/config/app_config.py,e\7\e7a8f69b82d0d0839cd67ff968caeb054957923f
\ No newline at end of file
.idea/vcs.xml
0 → 100644
View file @
91d82bdc
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
"$PROJECT_DIR$"
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
script/core/handlers/postgresql.py
View file @
91d82bdc
...
...
@@ -2,63 +2,50 @@ from sqlalchemy import MetaData
from
sqlalchemy
import
Column
,
Integer
,
String
,
MetaData
,
text
from
script.core.schema.postgresql
import
Employee
,
Model
from
script.utils.postgresql_connection
import
session
from
script.utils.postgresql_utils
import
Utils
my_utils
=
Utils
()
class
EmployeeData
:
@
staticmethod
def
insert_data
(
request_data
):
try
:
employee_data
=
Model
(
emp_id
=
request_data
.
emp_id
,
emp_name
=
request_data
.
emp_name
,
emp_department
=
request_data
.
emp_department
,
emp_sal
=
request_data
.
emp_sal
)
session
.
add
(
employee_data
)
temp
=
my_utils
.
insert_query
(
request_data
)
session
.
add
(
temp
)
session
.
commit
()
return
employee_data
return
temp
except
Exception
as
e
:
print
(
e
,
"Error Detected in inserting"
)
@
staticmethod
def
find_data
(
emp_id
):
try
:
employee_data
=
session
.
query
(
Model
)
.
all
()
list_
=
[]
for
data
in
employee_data
:
list_
.
append
({
"emp_id"
:
data
.
emp_id
,
"emp_name"
:
data
.
emp_name
,
"emp_department"
:
data
.
emp_department
,
"emp_sal"
:
data
.
emp_sal
})
return
list_
return
employee_data
header
=
[{
"label"
:
col
.
replace
(
"_"
,
" "
)
.
title
(),
"value"
:
col
}
for
col
in
Model
.
__table__
.
columns
.
keys
()]
employee_data
=
session
.
query
(
Model
)
.
all
()
return
{
"header"
:
header
,
"body"
:
employee_data
}
except
Exception
as
e
:
print
(
e
,
"Error Detected in finding employee data"
)
@
staticmethod
def
update_data
(
request_data
,
emp_id
):
try
:
get_update
=
{
key
:
value
for
key
,
value
in
request_data
if
value
is
not
None
and
value
!=
'string'
and
value
!=
0
}
update_data
=
session
.
query
(
Model
)
.
filter
(
text
(
str
(
f
"emp_id={emp_id}"
))
)
.
update
(
get_update
)
temp
=
my_utils
.
update_query
(
request_data
,
emp_id
)
session
.
commit
()
print
(
update_data
)
return
update_data
return
temp
except
Exception
as
e
:
print
(
e
,
"Error detected in updating"
)
@
staticmethod
def
delete_data
(
emp_id
):
try
:
data
=
session
.
query
(
Model
)
.
filter_by
(
emp_id
=
emp_id
)
.
first
(
)
session
.
delete
(
data
)
temp
=
my_utils
.
delete_query
(
emp_id
)
session
.
delete
(
temp
)
session
.
commit
()
return
data
return
temp
except
Exception
as
e
:
print
(
e
,
"Error detected in deleting"
)
script/service/postgres.py
View file @
91d82bdc
...
...
@@ -25,7 +25,7 @@ async def delete_item(emp_id: int):
@
router
.
post
(
APIEndpoints
.
update
)
async
def
update_item
(
emp_id
:
int
,
request_data
:
Employee
):
try
:
handler
.
update_data
(
request_data
,
emp_id
)
handler
.
update_data
(
request_data
,
emp_id
)
return
DefaultResponse
(
message
=
"Successfully Updated"
,
status
=
"success"
)
except
ValueError
:
return
DefaultResponse
(
message
=
"Due to value error"
)
...
...
script/utils/postgresql_utils.py
View file @
91d82bdc
from
script.core.schema.postgresql
import
Model
from
script.utils.postgresql_connection
import
session
class
Utils
:
@
staticmethod
def
insert_query
(
request_data
):
employee_data
=
Model
(
emp_id
=
request_data
.
emp_id
,
emp_name
=
request_data
.
emp_name
,
emp_department
=
request_data
.
emp_department
,
emp_sal
=
request_data
.
emp_sal
)
return
employee_data
@
staticmethod
def
find_query
(
emp_id
):
employee_data
=
session
.
query
(
Model
)
.
all
()
list_
=
[]
for
data
in
employee_data
:
list_
.
append
({
"emp_id"
:
data
.
emp_id
,
"emp_name"
:
data
.
emp_name
,
"emp_department"
:
data
.
emp_department
,
"emp_sal"
:
data
.
emp_sal
})
return
list_
return
employee_data
@
staticmethod
def
update_query
(
request_data
,
emp_id
):
get_update
=
{
key
:
value
for
key
,
value
in
request_data
if
value
is
not
None
and
value
!=
'string'
and
value
!=
0
}
update_data
=
session
.
query
(
Model
)
.
filter
(
Model
.
emp_id
==
emp_id
)
.
update
(
get_update
)
return
update_data
@
staticmethod
def
delete_query
(
emp_id
):
data
=
session
.
query
(
Model
)
.
filter_by
(
emp_id
=
emp_id
)
.
first
()
return
data
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