Compare commits

...

6 Commits

Author SHA1 Message Date
6a19ae637b training table 2021-02-23 16:49:24 +01:00
e767149802 connect on db obj creation 2021-02-23 16:45:58 +01:00
df277f4548 init_database() 2021-02-23 16:45:41 +01:00
3f0f292ded indexes instead of keys to address the ini content 2021-02-23 16:45:23 +01:00
ec6f64dcea DDL file 2021-02-23 16:31:06 +01:00
871d9abf98 mail login 2021-02-23 16:27:03 +01:00
2 changed files with 26 additions and 1 deletions

12
init.sql Normal file
View File

@ -0,0 +1,12 @@
create table if not exists training(
id integer primary key,
medium varchar(255) not null,
uuid uuid not null,
t timestamp with time zone not null,
lat float not null,
lon float not null,
speed float not null,
altitude float not null,
distance float not null,
kcal int not null
);

15
main.py
View File

@ -5,7 +5,20 @@ from sqlalchemy import create_engine
config = configparser.ConfigParser().read('config.ini')
db = create_engine(f"postgresql://{config['db']['username']}:{config['db']['password']}@{config['db']['host']}/{config['db']['database']}")
db = create_engine(f"postgresql://{config['db'][1]}:{config['db'][2]}@{config['db'][0]}/{config['db'][3]}").connect()
mail = IMAP4(host=config['mail'][0])
def init_database():
with open('init.sql') as f:
db.execute('\n'.join(f.readlines()))
def get_gpx_files_from_mail():
mail.login(config['mail'][1], config['mail'][2])
mail.logout()
def main():