Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Francois Mares
NF18 - Projet SCF - Groupe 5
Commits
a2cf275a
Commit
a2cf275a
authored
May 20, 2021
by
Clement Lucas
Browse files
Ajout des fonctions création, insertion, suppression à partir des fichiers .sql
parent
86f51c5e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Python/SQL.py
View file @
a2cf275a
...
...
@@ -22,6 +22,36 @@ class SQL():
def
_connexion
(
self
):
return
psycopg2
.
connect
(
f
"dbname='
{
self
.
_DATABASE
}
' user ='
{
self
.
_USER
}
' host='
{
self
.
_HOST
}
' password='
{
self
.
_PASSWORD
}
'"
)
def
creation_bdd
(
self
):
try
:
connexion
=
self
.
_connexion
()
cur
=
connexion
.
cursor
()
cur
.
execute
(
open
(
"../SQL/TABLE.sql"
,
"r"
).
read
())
connexion
.
commit
()
return
except
psycopg2
.
Error
as
e
:
print
(
"Message système :"
,
e
)
def
suppression_bdd
(
self
):
try
:
connexion
=
self
.
_connexion
()
cur
=
connexion
.
cursor
()
cur
.
execute
(
open
(
"../SQL/DELETE.sql"
,
"r"
).
read
())
connexion
.
commit
()
return
except
psycopg2
.
Error
as
e
:
print
(
"Message système :"
,
e
)
def
insertion_bdd
(
self
):
try
:
connexion
=
self
.
_connexion
()
cur
=
connexion
.
cursor
()
cur
.
execute
(
open
(
"../SQL/DATA.sql"
,
"r"
).
read
())
connexion
.
commit
()
return
except
psycopg2
.
Error
as
e
:
print
(
"Message système :"
,
e
)
# PUBLIC:
def
requete_sql
(
self
,
sql
):
...
...
Write
Preview
Supports
Markdown
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