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
67a288df
Commit
67a288df
authored
May 18, 2021
by
David Gustavo De La Rocha Ramirez
Browse files
Mis a jour des fichiers .SQL
parents
dfb7f492
d867a851
Changes
3
Hide whitespace changes
Inline
Side-by-side
Python/.gitkeep
0 → 100644
View file @
67a288df
Python/Client.py
0 → 100644
View file @
67a288df
from
SQL
import
SQL
class
Client
(
SQL
):
def
__init__
(
self
):
super
(
self
)
print
(
"Nouveau client
\n
"
)
def
consulter_horaire_train
(
self
):
print
(
"rien"
)
def
rechercher_trajet
(
self
,
depart
,
arrivee
):
self
.
requete_sql
(
"INSERT INTO exemple VALUES('exemple')"
)
print
(
"rien"
)
Python/SQL.py
0 → 100644
View file @
67a288df
import
psycopg2
class
SQL
():
HOST
=
'tuxa.sme.utc'
DATABASE
=
'dbnf18p103'
PASSWORD
=
'RdhPbg7H'
USER
=
'nf18p103'
def
requete_sql
(
self
,
sql
):
try
:
connexion
=
psycopg2
.
connect
(
f
"dbname='
{
DATABASE
}
' user ='
{
USER
}
' host='
{
HOST
}
' password='
{
PASSWORD
}
'"
)
cur
=
connexion
.
cursor
()
cur
.
execute
(
sql
)
rows
=
cur
.
fetchall
()
connexion
.
close
()
return
rows
except
psycopg2
.
IntegrityError
as
e
:
connexion
.
rollback
()
print
(
"Message système :"
,
e
)
def
insert_into
(
self
,
classe
,
values
):
sql
=
"INSERT INTO "
+
classe
+
" VALUES("
+
values
+
")"
try
:
connexion
=
psycopg2
.
connect
(
f
"dbname='
{
DATABASE
}
' user ='
{
USER
}
' host='
{
HOST
}
' password='
{
PASSWORD
}
'"
)
cur
=
connexion
.
cursor
()
cur
.
execute
(
sql
)
connexion
.
close
()
except
psycopg2
.
DataError
as
e
:
connexion
.
rollback
()
print
(
"Message système :"
,
e
)
\ No newline at end of file
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