Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import MySQLdb
- import django
- from django.conf import settings
- settings.configure()
- from django.contrib.contenttypes.models import ContentType
- def main():
- user_type = ContentType.objects.get(app_label='ZingyHome', model='User')
- User = user_type.model_class()
- conn = MySQLdb.connect(host='127.0.0.1', user='root', passwd='root', db='zingyhomes')
- cursor = conn.cursor(MySQLdb.cursors.DictCursor)
- cursor.execute("select * from tbl_personaldetails")
- rows = cursor.fetchall()
- for row in rows:
- user = User.objects.create(
- id = row['customerId'],
- first_name = row['firstName'],
- last_name = row['lastName'],
- email = row['emailAddress'],
- token = row['verificationCode'],
- user_type = row['type'],
- is_email_validated = True if row['emailVerification'] is 1 else False,
- date_joined = row['addDate'],
- date_modified = row['lastUpdated'],
- phone = row['phone'],
- address = row['address'],
- Iam = row['Iam'],
- about_yourself = row['about_yourself'],
- image = row['imagePath'],
- pincode = row['pin'],
- mailchimplistid = row['mailchimpListId'],
- Key_project_holded = row['keyProjectHolded'],
- provide_service_in = row['provide_service_in'],
- )
- country, country_created = Country.objects.get_or_create(name=row['country'])
- state, state_created = State.objects.get_or_create(name=row['state'])
- city, city_created = City.objects.get_or_create(name=row['city'])
- user.country = country
- user.state = state
- user.city = city
- user.set_password(row['passwords'])
- user.save()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement