mardi 9 août 2016

pymysql inserting random numbers into a column using python

I want to insert random numbers including and between 1 to 100 using python to MySQL database column.

I will generate random numbers from python using

random.randrange(1,100)

I have added MYSQL query to the database

 CREATE SCHEMA `test` ;
CREATE TABLE `exercise`.`random_values` (
  `id` INT NOT NULL AUTO_INCREMENT COMMENT '',
  `rnd_value` INT NULL COMMENT '',
  PRIMARY KEY (`id`)  COMMENT '');

I use pymysql connector to insert data into MySQL database. Can anyone suggest me to how to insert these random numbers into a MySQL column using python?




Aucun commentaire:

Enregistrer un commentaire