r/SQL • u/kiwiboy94 • Mar 23 '20
MySQL Beginner project for SQL. This is a simple python script to scrape stock prices off NASDAQ API and feed it to MySQL.
3
5
u/benthook Mar 23 '20
that is some well commented code
0
Mar 23 '20
[deleted]
1
u/Seven-of-Nein Mar 24 '20
What would a parametized prepared statement look like? Asking for a noob.
1
u/mantennnn Jul 16 '20
Basically strip inputs of any special characters that would result in mysql injection and use variables to swap there values. it works like print(%s, variable);
1
u/w_savage Mar 23 '20
are you our leader from the discord server??
2
2
u/r0ck0 Mar 24 '20
The screenshot gave me old skool Winamp vibes!
1
u/MacheenLurning Apr 14 '20
Damn Winamp skins were the best...
OP I’ve been thinking about utilizing something like this as one of my new project ideas appreciate the insight.
1
1
1
0
Mar 23 '20
[deleted]
3
u/kiwiboy94 Mar 23 '20
Oh yes you do. I have instructed on the readme document on github that users are required to create a database call 'stock' and a table with a name similar to the stock symbol. Initially I was thinking of incorporating that into the code (i.e make user drop database, create table and add value each time they run the script). However I am planning to do this daily, so I can't really work a way around it other than to ask my user to create the db and table beforehand.
5
u/Oxford89 Director, BI Mar 23 '20
Opportunity to normalize a little here. Create a table called stocks with Id and Ticker Symbol. Create a record for the target stock in that table. Then write the time series price data into a separate stock_prices table with a FK reference to the stocks table. Doesn't make sense to create a new table for every single stock.
2
u/kiwiboy94 Mar 23 '20
Ya I thought of that as well. Initially I thought I am going to work on a single table if I am going to work with lots of stocks. However I am just going to work with 2 at the moment so I just keep them in separate tables
2
u/tx69er Mar 23 '20
If you are learning, you should try to aim to learn to do things right. This is the time when you have the freedom to change things around and in the process increase your understanding even more! I say do it!
2
9
u/codeforces_help Mar 23 '20
Yes, the database schema needs to exist before the application needs be run. Now, how do you achieve is upto you. Also, databases are built on a client server model. So it can exist on another machine whose IP:3306 you can access. This will give your application a connection to that database hosted remotely. For beginners I would suggest host database locally, on the same machine as your application and the IP becomes 127.0.0.1 which you can easily access.
25
u/kiwiboy94 Mar 23 '20
Github Link