Private
Public Access
1
0

ordering in mysql

This commit is contained in:
Sander Roosendaal
2019-10-22 14:33:36 +02:00
parent 964416362d
commit 6de6a0dae1
2 changed files with 22 additions and 26 deletions

View File

@@ -1911,12 +1911,12 @@ def read_cols_df_sql(ids, columns, convertnewtons=True):
# columns=cls,
# ))
elif len(ids) == 1:
query = sa.text('SELECT {columns} FROM strokedata WHERE workoutid={id}'.format(
query = sa.text('SELECT {columns} FROM strokedata WHERE workoutid={id} ORDER BY time ASC'.format(
id=ids[0],
columns=cls,
))
else:
query = sa.text('SELECT {columns} FROM strokedata WHERE workoutid IN {ids}'.format(
query = sa.text('SELECT {columns} FROM strokedata WHERE workoutid IN {ids} ORDER BY time ASC'.format(
columns=cls,
ids=tuple(ids),
))
@@ -1953,7 +1953,7 @@ def read_cols_df_sql(ids, columns, convertnewtons=True):
def read_df_sql(id):
engine = create_engine(database_url, echo=False)
df = pd.read_sql_query(sa.text('SELECT * FROM strokedata WHERE workoutid={id}'.format(
df = pd.read_sql_query(sa.text('SELECT * FROM strokedata WHERE workoutid={id} ORDER BY time ASC'.format(
id=id)), engine)
engine.dispose()