Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- import pymysql
- # Open file with elail addresses : separate email @dress per line
- file = open('my_text_file.txt','r')
- fo = file.readlines()
- # Connect to the database
- connection = pymysql.connect(host='mariadb55.websupport.sk',
- port=3310,
- user='my_sql_user',
- passwd='my_sql_pass',
- db='my_sql_db',
- charset='utf8mb4',
- cursorclass=pymysql.cursors.DictCursor)
- # Read email from lines and push to DB
- for line in fo:
- print line.replace('\n','')
- with connection.cursor() as cursor:
- # Create a new record
- sql = "INSERT INTO email_unreg(email,kampan) VALUES (%s, %s)"
- cursor.execute(sql, (line,'Nedorucene'))
- connection.commit()
- print "OK"
- print "Finish"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement