Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Code Python
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
procom2022-robotise
Code Python
Commits
a7e71a73
Commit
a7e71a73
authored
Feb 27, 2023
by
Adrien Chabod
Browse files
Options
Downloads
Patches
Plain Diff
maj machine
parent
d5a239ae
Branches
Branches containing commit
No related tags found
1 merge request
!1
MAJ BDD + Data commande fonctionnel
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
bibliotheques/sql/sql.py
+13
-2
13 additions, 2 deletions
bibliotheques/sql/sql.py
tests/test_sql_formalize.py
+4
-1
4 additions, 1 deletion
tests/test_sql_formalize.py
tests/test_sql_req.py
+5
-1
5 additions, 1 deletion
tests/test_sql_req.py
with
23 additions
and
4 deletions
.gitignore
+
1
−
0
View file @
a7e71a73
.DS_Store
__pycache__
bin/
*.txt
This diff is collapsed.
Click to expand it.
bibliotheques/sql/sql.py
+
13
−
2
View file @
a7e71a73
...
...
@@ -79,13 +79,24 @@ def mysql_add_ingredient(nom_ingredient: str):
cursor
.
close
()
connection
.
close
()
def
mysql_maj_machine
(
maj
:
tuple
):
connection
=
connect_db
()
cursor
=
connection
.
cursor
()
cursor
.
execute
(
"
UPDATE ingredient SET id_bec = NULL
"
)
for
k
in
range
(
6
):
cursor
.
execute
(
"
UPDATE machine SET quantite = %s WHERE id_bec = %s
"
,
(
maj
[
k
][
2
],
maj
[
k
][
0
],))
cursor
.
execute
(
"
UPDATE ingredient SET id_bec = %s WHERE id_ingredient = %s
"
,
(
maj
[
k
][
0
],
maj
[
k
][
1
],))
connection
.
commit
()
cursor
.
close
()
connection
.
close
()
def
formalize_data_list
(
function
):
initial_data
=
function
()
new_data
=
"
/
"
.
join
([
"
,
"
.
join
([
str
(
k
)
for
k
in
x
])
for
x
in
initial_data
])
return
str
(
new_data
)
def
unformalize_data_list
(
initial_data
):
def
unformalize_data_list
(
initial_data
:
str
):
sublists
=
initial_data
.
split
(
"
/
"
)
sublist_data
=
[
x
.
split
(
"
,
"
)
for
x
in
sublists
]
new_data
=
[[
int
(
k
)
for
k
in
x
]
for
x
in
sublist_data
]
new_data
=
[[
str
(
k
)
for
k
in
x
]
for
x
in
sublist_data
]
return
tuple
(
new_data
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tests/test_sql_formalize.py
+
4
−
1
View file @
a7e71a73
...
...
@@ -2,4 +2,7 @@ from bibliotheques.sql.sql import formalize_data_list, unformalize_data_list
input
=
"
0,None,None/1,6,0/2,2,0/3,None,None/4,None,None/5,None,None
"
unformalize_data_list
(
input
)
\ No newline at end of file
print
(
type
(
unformalize_data_list
(
input
[
1
])))
new_data
=
unformalize_data_list
(
input
)
print
(
new_data
[
0
][
0
])
\ No newline at end of file
This diff is collapsed.
Click to expand it.
tests/test_sql_req.py
+
5
−
1
View file @
a7e71a73
from
bibliotheques.sql.sql
import
*
input
=
"
0,None,None/1,6,0/2,2,0/3,None,None/4,None,None/5,None,None
"
#id_bec,id_ingredient,quantite
print
(
mysql_get_cocktail_list
())
print
(
mysql_get_ingredient_list
())
print
(
mysql_get_quantite_machine
())
...
...
@@ -8,3 +10,5 @@ print(mysql_get_cocktail_composition_without_bec(1))
print
(
mysql_get_cocktail_composition_with_bec
(
1
))
print
(
mysql_get_bec_from_ingredient
(
1
))
mysql_add_ingredient
(
"
test
"
)
mysql_maj_machine
(
unformalize_data_list
(
input
))
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
sign in
to comment