Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Postgresql crud operations
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
vipul.v
Postgresql crud operations
Commits
c1a70b22
Commit
c1a70b22
authored
Mar 27, 2023
by
vipul.v
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crud operation second
parent
2a1e6c47
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
0 deletions
+66
-0
script/utils/inventory_utils.py
script/utils/inventory_utils.py
+66
-0
No files found.
script/utils/inventory_utils.py
0 → 100644
View file @
c1a70b22
from
sqlalchemy
import
Column
,
Integer
,
String
,
MetaData
,
text
from
sqlalchemy
import
Table
from
script.core.db.postgresql_connector
import
session
from
script.core.schema.inventory
import
Inventory
metadata
=
MetaData
()
class
SqlUtility
:
@
staticmethod
def
create_file
():
try
:
inventory_table
=
Table
(
'inventory_data'
,
metadata
,
Column
(
'order_id'
,
Integer
,
primary_key
=
True
,
index
=
True
),
Column
(
'customer_name'
,
String
),
Column
(
'status'
,
String
),
Column
(
'sales_order'
,
Integer
,
index
=
True
)
)
return
inventory_table
except
Exception
as
e
:
print
(
e
,
"Error detected in updating"
)
@
staticmethod
def
insert_file
(
request_data
):
try
:
new_inventory_data
=
Inventory
(
customer_name
=
request_data
.
customer_name
,
status
=
request_data
.
status
,
sales_order
=
request_data
.
sales_order
)
return
new_inventory_data
except
Exception
as
e
:
print
(
e
,
"Error detected in updating"
)
@
staticmethod
def
fetch_file
():
try
:
inventory_data
=
session
.
query
(
Inventory
)
.
all
()
list_
=
[]
for
data
in
inventory_data
:
list_
.
append
({
"order_id"
:
data
.
order_id
,
"customer_name"
:
data
.
customer_name
,
"status"
:
data
.
status
,
"sales_order"
:
data
.
sales_order
})
return
list_
except
Exception
as
e
:
print
(
e
,
"Error detected in updating"
)
@
staticmethod
def
update_file
(
request_data
,
order_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
(
Inventory
)
.
filter
(
text
(
str
(
f
"order_id={order_id}"
))
)
.
update
(
get_update
)
return
update_data
except
Exception
as
e
:
print
(
e
,
"Error detected in updating"
)
@
staticmethod
def
delete_file
(
order_id
):
try
:
data
=
session
.
query
(
Inventory
)
.
filter_by
(
order_id
=
order_id
)
.
first
()
return
data
except
Exception
as
e
:
print
(
e
,
"Error detected in updating"
)
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