Skip to content
Snippets Groups Projects
Commit 3832b565 authored by Jacques Grelet's avatar Jacques Grelet
Browse files

rename some column in station table

parent e1ced3d2
No related branches found
No related tags found
No related merge requests found
...@@ -24,13 +24,13 @@ table_station = """ ...@@ -24,13 +24,13 @@ table_station = """
CREATE TABLE station ( CREATE TABLE station (
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
header TEXT, header TEXT,
station INT NOT NULL UNIQUE, STATION INT NOT NULL UNIQUE,
date_time TEXT NOT NULL UNIQUE, DATE_TIME TEXT NOT NULL UNIQUE,
end_date_time TEXT, end_date_time TEXT,
julian_day REAL NOT NULL UNIQUE, DAYD REAL NOT NULL UNIQUE,
latitude REAL NOT NULL, LATITUDE REAL NOT NULL,
lat TEXT, lat TEXT,
longitude REAL NOT NULL, LONGITUDE REAL NOT NULL,
lon TEXT, lon TEXT,
max_depth REAL, max_depth REAL,
bath REAL, bath REAL,
...@@ -46,7 +46,7 @@ table_data = """ ...@@ -46,7 +46,7 @@ table_data = """
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
station_id INTEGER, station_id INTEGER,
FOREIGN KEY (station_id) FOREIGN KEY (station_id)
REFERENCES station (id) REFERENCES STATION (id)
); """ ); """
class Profile: class Profile:
...@@ -198,19 +198,19 @@ class Profile: ...@@ -198,19 +198,19 @@ class Profile:
self.__data[k] = np.empty(n) self.__data[k] = np.empty(n)
# get data from table station and fill array # get data from table station and fill array
#query = self.db.query('SELECT julian_day, latitude, longitude, bath FROM station') #query = self.db.query('SELECT DAYD, latitude, longitude, bath FROM station')
query = self.db.select('station', ['id','station', 'julian_day', 'end_date_time', query = self.db.select('station', ['id','STATION', 'DAYD', 'end_date_time',
'latitude', 'longitude', 'bath']) 'LATITUDE', 'LONGITUDE', 'bath'])
logging.debug(query) logging.debug(query)
profil_pk = [] profil_pk = []
for idx, item in enumerate(query): for idx, item in enumerate(query):
profil_pk.append(item['id']) profil_pk.append(item['id'])
self.__data['PROFILE'][idx] = item['station'] self.__data['PROFILE'][idx] = item['STATION']
#print(item['station']) #print(item['STATION'])
self.__data['TIME'][idx] = item['julian_day'] self.__data['TIME'][idx] = item['DAYD']
#self.__data['END_TIME'][idx] = item['end_date_time'] #self.__data['END_TIME'][idx] = item['end_date_time']
self.__data['LATITUDE'][idx] = item['latitude'] self.__data['LATITUDE'][idx] = item['LATITUDE']
self.__data['LONGITUDE'][idx] = item['longitude'] self.__data['LONGITUDE'][idx] = item['LONGITUDE']
self.__data['BATH'][idx] = item['bath'] self.__data['BATH'][idx] = item['bath']
# initialize array # initialize array
...@@ -282,8 +282,8 @@ class Profile: ...@@ -282,8 +282,8 @@ class Profile:
# by default, station or profile number is extract from the filename # by default, station or profile number is extract from the filename
if station_regex != None and station_regex.search(file): if station_regex != None and station_regex.search(file):
[station] = station_regex.search(file).groups() [station] = station_regex.search(file).groups()
sql['station'] = int(station) sql['STATION'] = int(station)
logging.debug(f"Station match: {sql['station']}") logging.debug(f"Station match: {sql['STATION']}")
with fileinput.input( with fileinput.input(
...@@ -322,7 +322,7 @@ class Profile: ...@@ -322,7 +322,7 @@ class Profile:
if k == "station" and self.__regex[k].search(self.__header): if k == "station" and self.__regex[k].search(self.__header):
[station] = self.__regex[k].search(self.__header).groups() [station] = self.__regex[k].search(self.__header).groups()
#print("station: {}, type: {}".format(station, type(station))) #print("station: {}, type: {}".format(station, type(station)))
sql['station'] = int(station) sql['STATION'] = int(station)
# key is DATETIME # key is DATETIME
if k == "DATETIME" and self.__regex[k].search(self.__header): if k == "DATETIME" and self.__regex[k].search(self.__header):
...@@ -396,8 +396,8 @@ class Profile: ...@@ -396,8 +396,8 @@ class Profile:
dtf = cfg[device.lower()]['dateTimeFormat'] dtf = cfg[device.lower()]['dateTimeFormat']
else: else:
dtf = "%d/%m/%Y %H:%M:%S" dtf = "%d/%m/%Y %H:%M:%S"
sql['date_time'] = dt.strptime(dateTime, dtf) sql['DATE_TIME'] = dt.strptime(dateTime, dtf)
sql['julian_day'] = tools.dt2julian(sql['date_time']) sql['DAYD'] = tools.dt2julian(sql['DATE_TIME'])
# insert or query return last cursor, get the value of the primary key # insert or query return last cursor, get the value of the primary key
# with lastrowid # with lastrowid
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment