Код: Выделить всё
from typing import Generator
from requests_html import HTMLSession
import pandas as pd
import numpy as np
from itertools import islice
import mysql.connector
from sqlalchemy import create_engine
horses = "Love Your Work (IRE)"
terrain = "Standard"
courses = "Doncaster"
distances = "1m"
pos1 = "1"
pos2 = "2"
mydb = mysql.connector.connect(
host="localhost",
user="root",
password="",
database="horseracinguk"
)
#engine = create_engine("mysql+mysqlconnector://root:new_password@localhost/mydatabase")
engine = create_engine('mysql://root@localhost/mydbname?')
mycursor = mydb.cursor(dictionary=True)
mycursor.execute("SELECT * FROM mytable")
myresult = mycursor.fetchall()
for row in myresult:
if horses == row["horse"]:
if ((terrain == row["going"]) and (pos1 == row["pos"])):
pointsgoing1 = 2
horse = row["horse"]
terrain = row["going"]
course = row["course"]
distance = row["dist"]
position = row["pos"]
print(horse, terrain, course, distance, position, pointsgoing1)
Есть предложения?
Спасибо
Подробнее здесь: https://stackoverflow.com/questions/787 ... -in-python