Quantcast
Channel: MySQL Forums - Connector/Python
Viewing all articles
Browse latest Browse all 384

Using Column Names as a Variable (1 reply)

$
0
0
First Post!

Thank you in advance for helping me with this question that I promise am not trying to make difficult.


I am writing a python script on my PI to connect to my SQL database on a subscription hosting site with a Cpanel. My program is grabbing an API from a gambling site to see the over/under on every sports game(that i care about) every hour and recording the hourly difference from the previous hour before the event. My hours are from 60 hours before the game to 0 hours before.

I can easily create a CSV and access it there, but my problem comes when I try to log it into SQL.

I am finding myself with 60 + columns in my table that I am trying to fill with odds.

Now the problem:

I have 60+ columns I need to fill with odds..

Each sport has a unique game ID that I have set as my primary key. Instead of updating every column in the row that I would like to update, is it possible to use a variable to find the column I want?

Right now my columns are labeled 60, 59, 58, 57, 56, 55...etc then the values of the rows hold the over/under at that hour leading up to the match.

Is there any way that I can use my HOURSBEFOREMATCH integer as a variable to use that as a variable as a column name to INSERT it in the correct place?

Hope this makes sense..

Thanks alot guys!

Viewing all articles
Browse latest Browse all 384

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>