python - having trouble with mysql migration (can't multiply sequence by non-int of type 'tuple') -


i havnig troulble migrating..i first tried

python manage.py migrate qablog

and didn't work. tried

python manage.py migrate qablog --fake-initial 

and didn't work too.. googled again , people talking changing settings.py changed things changing use_tz false ..

python manage.py makemigrations qablog

worked though...can me this? .. python version: 3.4.4 mysql server version: 5.7 django version: 1.10.3

the error log below:

c:\inetpub\wwwroot\test>python manage.py migrate qablog --fake-initial operations perform:   apply migrations: qablog running migrations:   applying contenttypes.0001_initial... faked   applying auth.0001_initial... ok   applying qablog.0001_initial... ok traceback (most recent call last):   file "manage.py", line 22, in <module>     execute_from_command_line(sys.argv)   file "c:\python34\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line     utility.execute()   file "c:\python34\lib\site-packages\django\core\management\__init__.py", line 359, in execute     self.fetch_command(subcommand).run_from_argv(self.argv)   file "c:\python34\lib\site-packages\django\core\management\base.py", line 294,  in run_from_argv     self.execute(*args, **cmd_options)   file "c:\python34\lib\site-packages\django\core\management\base.py", line 345,  in execute     output = self.handle(*args, **options)   file "c:\python34\lib\site-packages\django\core\management\commands\migrate.py ", line 224, in handle     self.verbosity, self.interactive, connection.alias, apps=post_migrate_apps, plan=plan,   file "c:\python34\lib\site-packages\django\core\management\sql.py", line 53, n emit_post_migrate_signal     **kwargs   file "c:\python34\lib\site-packages\django\dispatch\dispatcher.py", line 191, in send     response = receiver(signal=self, sender=sender, **named)   file "c:\python34\lib\site-packages\django\contrib\auth\management\__init__.py ", line 83, in create_permissions     permission.objects.using(using).bulk_create(perms)   file "c:\python34\lib\site-packages\django\db\models\query.py", line 452, in b ulk_create     ids = self._batched_insert(objs_without_pk, fields, batch_size)   file "c:\python34\lib\site-packages\django\db\models\query.py", line 1068, in _batched_insert     self._insert(item, fields=fields, using=self.db)   file "c:\python34\lib\site-packages\django\db\models\query.py", line 1045, in _insert     return query.get_compiler(using=using).execute_sql(return_id)   file "c:\python34\lib\site-packages\django\db\models\sql\compiler.py", line 10 53, in execute_sql     sql, params in self.as_sql():   file "c:\python34\lib\site-packages\django\db\models\sql\compiler.py", line 10 38, in as_sql     result.append(self.connection.ops.bulk_insert_sql(fields, placeholder_rows))    file "c:\python34\lib\site-packages\mysql\connector\django\operations.py", lin e 223, in bulk_insert_sql     return "values " + ", ".join([items_sql] * num_values) typeerror: can't multiply sequence non-int of type 'tuple' 

[manage.py]

#!/usr/bin/env python import os import sys  if __name__ == "__main__":     os.environ.setdefault("django_settings_module", "swingqa.settings")     try:         django.core.management import execute_from_command_line     except importerror:         # above import may fail other reason. ensure         # issue django missing avoid masking other         # exceptions on python 2.         try:             import django         except importerror:             raise importerror(                 "couldn't import django. sure it's installed , "                 "available on pythonpath environment variable? did "                 "forget activate virtual environment?"             )         raise     execute_from_command_line(sys.argv) 

[models.py]

from django.db import models django.utils import timezone   class post(models.model):     author = models.foreignkey('auth.user')     title = models.charfield(max_length=200)     text = models.textfield()     created_date = models.datetimefield(             default=timezone.now)     published_date = models.datetimefield(             blank=true, null=true)  def publish(self):     self.published_date = timezone.now()     self.save()  def __str__(self):     return self.title 

and migration file.. looked inside qablog > migrations folder , there init , 0001_initial file.. init file empty (it's blank inside) , 0001_ initial file below

[0001_initial.py]

# -*- coding: utf-8 -*- # generated django 1.10.3 on 2016-11-10 07:56 __future__ import unicode_literals  django.conf import settings django.db import migrations, models import django.db.models.deletion import django.utils.timezone   class migration(migrations.migration):      initial = true      dependencies = [         migrations.swappable_dependency(settings.auth_user_model),     ]      operations = [         migrations.createmodel(             name='post',             fields=[                 ('id', models.autofield(auto_created=true, primary_key=true, serialize=false, verbose_name='id')),                 ('title', models.charfield(max_length=200)),                 ('text', models.textfield()),                 ('created_date', models.datetimefield(default=django.utils.timezone.now)),                 ('published_date', models.datetimefield(blank=true, null=true)),                 ('author', models.foreignkey(on_delete=django.db.models.deletion.cascade, to=settings.auth_user_model)),             ],         ),     ] 

i'd appreciate :-)

found solution question myself :-)

i don't know reason but

if change operations.py file in path below c:\python34\lib\site-packages\mysql\connector\django

especially part def bulk_insert_sql function is,,from

 def bulk_insert_sql(self, fields, num_values):         items_sql = "({0})".format(", ".join(["%s"] * len(fields)))         return "values " + ", ".join([items_sql] * num_values) 

to ...

def bulk_insert_sql(self, fields, placeholder_rows):     """     format sql bulk insert     """     placeholder_rows_sql = (", ".join(row) row in placeholder_rows)     values_sql = ", ".join("(%s)" % sql sql in placeholder_rows_sql)     return "values " + values_sql 

there no errors in doing python manage.py migrate qablog command.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -