-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdal.py
44 lines (38 loc) · 1.36 KB
/
dal.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import mysql.connector
from dotenv import load_dotenv
class Dal:
def __init__(self):
load_dotenv()
self.db = mysql.connector.connect(
host=MYSQL_SRV,
user=MYSQL_USR,
password=MYSQL_PW
)
def insert_rates(self, rates):
sqlString = '''insert into marketdata ('symbol', 'market', 'time',
'open', 'high', 'low', 'close',
'tick_volume', 'spread',
'real_volume', 'period',
'provider') values
'''
for rate in rates:
sqlString += symbolName
sqlString += "', "
sqlString += "'B3', '"
sqlString += str(row[0])
sqlString += "', '"
sqlString += str(row[1])
sqlString += "', '"
sqlString += str(row[2])
sqlString += "', '"
sqlString += str(row[3])
sqlString += "', '"
sqlString += str(row[4])
sqlString += "', '"
sqlString += str(row[5])
sqlString += "', '"
sqlString += str(row[6])
sqlString += "', '"
sqlString += str(row[7])
sqlString += "', 'TIMEFRAME_M5', 'Rico')"
conn.commit()