Created
August 7, 2014 02:48
-
-
Save BalicantaYao/466c4a9ba565bc38f8f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from random import randint | |
import pyodbc | |
from datetime import datetime | |
import random | |
cnxn = pyodbc.connect('DRIVER={SQL Server};SERVER=xxxxx;DATABASE=POC_HOUSEKEEPING;UID=xxxxx;PWD=xxxxxx') | |
cursor = cnxn.cursor() | |
for num in range(0,1000100): | |
try: | |
version = randint(1,1) | |
treeNode = randint(1,1000000) | |
values = randint(2,9) | |
level = randint(1,5) | |
year = random.choice(range(1950, 2000)) | |
month = random.choice(range(1, 12)) | |
day = random.choice(range(1, 28)) | |
birthDate = datetime(year, month, day) | |
cursor.execute("INSERT INTO TS_4_3(VERSIONID, TREENODEID, TARGETDATE, VALUE, UPDATEDAT, UPDATEDBY, CHANGEDSTATUSCODE, LEVELNUM) VALUES (?, ?, ?, ?, '', 0, 0, ?)" | |
, version, treeNode, birthDate, values, level) | |
cnxn.commit() | |
except pyodbc.IntegrityError: | |
print "Repeat Data" | |
pass | |
cursor.close() | |
cnxn.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment