Commit 23595e0a by JonathanMM

Gestion de la stationId Null

parent 14003b87
......@@ -4,6 +4,11 @@ from config import getMysqlConnection, getURLVelib
from adresseLib import getAdresse, getInsee
from gbfsLib import getStationIdByLatLong
def val(valeur):
if valeur is None:
return 'NULL'
return '"'+str(valeur)+'"'
def getAllStation():
mysql = getMysqlConnection()
......@@ -54,10 +59,10 @@ def getAllStation():
strDateOuverture = 'CURDATE()'
#On récupère également le stationId des données GTFS
stationId = getStationIdByLatLong(latitude, longitude)
requete = mysql.cursor()
requete.execute('INSERT INTO stations (code, name, longitude, latitude, type, dateOuverture, adresse, insee, stationId) VALUES \
('+str(codeStation)+', "'+str(infoStation['name'])+'", '+str(longitude)+', '+str(latitude)+', "'+str(infoStation['type'])+'", '+strDateOuverture+', "'+getAdresse(latitude, longitude)+'", '+str(getInsee(codeStation))+', '+str(stationId)+')')
('+val(codeStation)+', '+val(infoStation['name'])+', '+val(longitude)+', '+val(latitude)+', '+val(infoStation['type'])+', '+strDateOuverture+', '+val(getAdresse(latitude, longitude))+', '+val(getInsee(codeStation))+', '+val(stationId)+')')
stations.append(codeStation)
nbBike = int(etatStation['nbBike'])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment