40 lines
998 B
Python
40 lines
998 B
Python
##Imports
|
|
|
|
import sqlite3 as sql
|
|
import pandas as pd
|
|
import os
|
|
import datetime
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
|
|
def createMetadataTable():
|
|
"""Create the db table which contaign all data """
|
|
db = sql.connect("robotgowestdb.db")
|
|
c = db.cursor()
|
|
|
|
requestCreate = '''CREATE TABLE IF NOT EXISTS METADATA_TABLE (
|
|
[Id] INTEGER PRIMARY KEY,
|
|
[Place] TEXT,
|
|
[Start] TEXT
|
|
)'''
|
|
c.execute(requestCreate)
|
|
db.commit()
|
|
|
|
def insertMetadataElement(place : str , start : datetime):
|
|
"""Insert a new element in the metadat table
|
|
|
|
Args:
|
|
currency (str): name of the currency to fetch its metadata with the yFinance API
|
|
"""
|
|
db = sql.connect("robotgowestdb.db")
|
|
c = db.cursor()
|
|
request = f'''INSERT INTO METADATA_TABLE (Place,Start)
|
|
VALUES (
|
|
'{place}',
|
|
'{start}'
|
|
)'''
|
|
c.execute(request)
|
|
db.commit()
|
|
|
|
createMetadataTable()
|
|
insertMetadataElement("ici", datetime.datetime.now()) |