How to randomly fill in a table consisting of 3 columns, columns have the following types:
int(10) AUTO_INCREMENT- no need to fill itvarchar(150)date
Thank you in advance!
How to randomly fill in a table consisting of 3 columns, columns have the following types:
int(10) AUTO_INCREMENT - no need to fill itvarchar(150)dateThank you in advance!
If the base is in MySQL, on python you can do this (apt-get install python-mysqldb):
import stringimport randomimport datetimeimport MySQLdbmaxlen = 250nrecords = 1000def main(): db = MySQLdb.connect(host = "127.0.0.1", user = "user_name", passwd = "user_pass", db = "test") cursor = db.cursor() for item in xrange(nrecords): name = "".join(random.choice(string.letters) for i in xrange(maxlen)) date = datetime.datetime.now() sql = "INSERT INTO TABLE1 (NAME, DATE) VALUES (\"%s\", \"%s\")" % (name, date) cursor.execute(sql) cursor.close() db.close()if __name__ == "__main__": main() UPDATE table SET field = RAND ()
Source: https://ru.stackoverflow.com/questions/339937/
All Articles