MYsql Stored procedure only work the second time i execute it through python
I'm using python to create a data warehouse in MySQL. I'm using the MySQLdb package to connect python to MySQL. I am trying to create a table which will contain all dates from 2005 to 2018. First, I create the relevant table: cursor.execute(""" CREATE TABLE IF NOT EXISTS dim_date ( date_id int(11) NOT NULL AUTO_INCREMENT, date date, day int(11), month int(11), year int(11), day_name varchar(45), PRIMARY KEY (date_id), INDEX date_index (date)) """) Then, I run the following command to create and run the stored procedure that will fill in the dates: cursor.execute("DROP PROCEDURE IF EXISTS BuildDate;") cursor.execute("SET #currdate := '2005-01-01';") cursor.execute("SET #enddate := '2018-01-01';") cursor.execute(""" CREATE PROCEDURE BuildDate() BEGIN WHILE #currdate < #enddate DO INSERT INTO ntr_yelp_dw.dim_date (date, day, month, year, day_name) VALUES ( #currdate, DAY(#currdate), MONTH(#currdate), YEAR(#currdate), DAYNAME(#currdate) ); SET #currdate := DATE_ADD(#currdate, INTERVAL 1 DAY); END WHILE; END """) cursor.callproc("BuildDate") The thing is that when I run the stored procedure code, the stored procedure is created, but the data isn't filled. Only when I run it a second time, the data is created and inserted into the table. Any thoughts?
Memory allocation for numpy.array with copy=False?
Draw contours of detected objects using python and opencv
simple web crawler i need to eliminate the duplicate URL that present in the array
Python: comparing list to a string
Is there any way to write '\r' into a file on linux with python? [closed]
matplotlib retrieve color from plt.plot command
Why are tuples slower than lists at evaluating generators into themselves?
call and control git bash from python script in windows
How get in real time POST update with django and instagram api?
Binary search tree insert method
Log scale mathplotlib in Python?
Why does python come with so many similar, but subtly different functionality for fulfilling certain elementary computing tasks?
How to have adjacent elements reduced to a single element [closed]
adding row to pandas dataframe from series
Python3.4 PIP install error while building
“Settings” for a function in Python