Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Alexander Jabbour
356 group 40 project
Commits
2f68d534
Commit
2f68d534
authored
Dec 23, 2021
by
alexjubs
Browse files
welcome message
parent
049ddcbb
Changes
5
Hide whitespace changes
Inline
Side-by-side
client_jubs/__pycache__/get_attributes.cpython-310.pyc
deleted
100644 → 0
View file @
049ddcbb
File deleted
client_jubs/__pycache__/parser.cpython-310.pyc
deleted
100644 → 0
View file @
049ddcbb
File deleted
client_jubs/__pycache__/utils.cpython-310.pyc
deleted
100644 → 0
View file @
049ddcbb
File deleted
client_jubs/main.py
View file @
2f68d534
...
...
@@ -8,10 +8,20 @@ options_switchcase = {
}
if
__name__
==
"__main__"
:
print
(
'''
Welcome to our ECE 356 final project client!
insert - inserts an entry into the table
modify - modifies an entry in a table by primary key
delete - deletes a row (or mulitple rows) from the table
get - fetches a set of rows from a table in the DB
'''
)
while
True
:
command
=
input
(
"Command: "
).
split
()
if
len
(
command
)
==
0
:
continue
if
command
[
0
]
not
in
options_switchcase
:
print
(
f
"Error: command not in options. Options are:
\n
{
list
(
options_switchcase
.
keys
())
}
"
)
continue
...
...
client_jubs/utils.py
View file @
2f68d534
...
...
@@ -18,48 +18,48 @@ from parser import *
# 1. ask the base table
# 2.
def
handle_collecting_insert_args
(
attributes
,
new_
column
):
def
handle_collecting_insert_args
(
attributes
,
new_
row
):
# the first element in attributes is the PK
for
i
in
range
(
len
(
attributes
)):
if
i
==
0
:
new_
column
[
attributes
[
i
]]
=
input
(
f
"specify
{
attributes
[
i
]
}
(this is a PK - it is required): "
)
if
new_
column
[
attributes
[
i
]]
==
''
:
return
-
1
new_
row
[
attributes
[
i
]]
=
input
(
f
"specify
{
attributes
[
i
]
}
(this is a PK - it is required): "
)
if
new_
row
[
attributes
[
i
]]
==
''
:
return
-
1
continue
new_
column
[
attributes
[
i
]]
=
input
(
f
"specify
{
attributes
[
i
]
}
(blank space for none): "
)
new_
row
[
attributes
[
i
]]
=
input
(
f
"specify
{
attributes
[
i
]
}
(blank space for none): "
)
return
0
def
handle_collecting_modify_args
(
attributes
,
new_
column
):
def
handle_collecting_modify_args
(
attributes
,
new_
row
):
# the first element in attributes is the PK
for
i
in
range
(
len
(
attributes
)):
if
i
==
0
:
new_
column
[
attributes
[
i
]]
=
input
(
f
"specify
{
attributes
[
i
]
}
(this is a PK - it is required): "
)
if
new_
column
[
attributes
[
i
]]
==
''
:
return
-
1
new_
row
[
attributes
[
i
]]
=
input
(
f
"specify
{
attributes
[
i
]
}
(this is a PK - it is required): "
)
if
new_
row
[
attributes
[
i
]]
==
''
:
return
-
1
continue
new_
column
[
attributes
[
i
]]
=
input
(
f
"specify
{
attributes
[
i
]
}
(blank space for no change): "
)
new_
row
[
attributes
[
i
]]
=
input
(
f
"specify
{
attributes
[
i
]
}
(blank space for no change): "
)
return
0
def
insert_base_func
(
command
):
insert_entry_args
=
insert_entry_parser
.
parse_args
(
command
[
1
:])
new_
column
=
dict
()
new_
row
=
dict
()
# branch based on the table
if
handle_collecting_insert_args
(
attributes
=
get_attributes_from_tablename
[
insert_entry_args
.
table
],
new_
column
=
new_column
new_
row
=
new_row
)
==
-
1
:
return
print
(
f
"INSERTING
column
:
\n
{
new_
column
}
\n
into table
{
insert_entry_args
.
table
}
"
)
print
(
f
"INSERTING
row
:
\n
{
new_
row
}
\n
into table
{
insert_entry_args
.
table
}
"
)
def
modify_base_func
(
command
):
modify_table_args
=
modify_table_parser
.
parse_args
(
command
[
1
:])
new_
column
=
dict
()
new_
row
=
dict
()
# branch based on the table
if
handle_collecting_modify_args
(
attributes
=
get_attributes_from_tablename
[
modify_table_args
.
table
],
new_
column
=
new_column
new_
row
=
new_row
)
==
-
1
:
return
print
(
f
"INSERTING
column
:
\n
{
new_
column
}
\n
into table
{
modify_table_args
.
table
}
"
)
print
(
f
"INSERTING
row
:
\n
{
new_
row
}
\n
into table
{
modify_table_args
.
table
}
"
)
def
delete_base_func
(
command
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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