[p2pu-dev] Switching from mysql to sqlite3 for development

zuzel.vp zuzel.vp at gmail.com
Wed Aug 10 22:30:00 UTC 2011


The mysql setting can be commented and leave the sql one by default.

On Wed, Aug 10, 2011 at 3:29 PM, Jessica Ledbetter
<jessica at jessicaledbetter.com> wrote:
> On Wed, Aug 10, 2011 at 1:02 PM, zuzel.vp <zuzel.vp at gmail.com> wrote:
>> Now the question is what needs to be changed in the source code and
>> docs to make sqlite the default db for dev.
>
> I think we'd just update settings.local.dist.py Those that have their local
> settings to be mysql wouldn't need to replace with sqlite.
>
> Maybe we can do two full examples: mysql and sqlite. Kind of like how the
> drupal stuff is in there and we can uncomment it if we want to integrate. Or
> we could just have sqlite as the default since those that are using mysql
> probably have a little more experience?
>
>
>
>> I am working on finding
>> the second cause of problems while running the tests (both should be
>> related to django_nose since the second one we saw during the workshop
>> (admin.autodiscover runs multiple times and thus fails) appeared when
>> I upgraded django_nose).
>>
>> --
>> Thanks,
>>    Zuzel
>>
>> On Sat, Aug 6, 2011 at 10:13 PM, Greg Wilson <gvwilson at third-bit.com>
>> wrote:
>>> +1 for using sqlite3 by default for dev --- now, if only we could figure
>>> out
>>> why the tests are getting mangled.  Taavi?
>>> Thx,
>>> G
>>>
>>> On 11-08-06 9:52 PM, Jessica Ledbetter wrote:
>>>
>>> Actually this might be from a few commits ago. I think brianloveswords
>>> had
>>> this problem. I've been coding on branches so was a little behind on
>>> master.
>>>
>>> Did a syncdb migrate got this error in the browser:
>>> TemplateSyntaxError at /groups/django-101/content/documentation/
>>>
>>> Caught DoesNotExist while rendering: Signup matching query does not
>>> exist.
>>>
>>> If memory serves, this has happened before. So, I did what worked last
>>> time
>>> when things got a little wonky and that was drop the database and create
>>> it
>>> and do a syncdb --migrate again. Unfortunately, that trick didn't work.
>>>
>>> What I got doing migrate:
>>>
>>> Running migrations for replies:
>>>  - Migrating forwards to
>>>
>>> 0002_auto__del_field_pagecomment_page__add_field_pagecomment_scope_content_.
>>>  > replies:0001_initial
>>>  ! Error found during real run of migration! Aborting.
>>>
>>>  ! Since you have a database that does not support running
>>>  ! schema-altering statements in transactions, we have had
>>>  ! to leave it in an interim state between migrations.
>>>
>>> ! You *might* be able to recover with:   = DROP TABLE
>>> `replies_pagecomment`
>>> CASCADE; []
>>>
>>>  ! The South developers regret this has happened, and would
>>>  ! like to gently persuade you to consider a slightly
>>>  ! easier-to-deal-with DBMS.
>>>  ! NOTE: The error which caused the migration to fail is further up.
>>> Traceback (most recent call last):
>>>   File "./manage.py", line 26, in <module>
>>>     execute_manager(settings)
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/django/core/management/__init__.py",
>>> line 438, in execute_manager
>>>     utility.execute()
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/django/core/management/__init__.py",
>>> line 379, in execute
>>>     self.fetch_command(subcommand).run_from_argv(self.argv)
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/django/core/management/base.py",
>>> line 191, in run_from_argv
>>>     self.execute(*args, **options.__dict__)
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/django/core/management/base.py",
>>> line 220, in execute
>>>     output = self.handle(*args, **options)
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/django/core/management/base.py",
>>> line 351, in handle
>>>     return self.handle_noargs(**options)
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/south/management/commands/syncdb.py",
>>> line 99, in handle_noargs
>>>     management.call_command('migrate', **options)
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/django/core/management/__init__.py",
>>> line 166, in call_command
>>>     return klass.execute(*args, **defaults)
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/django/core/management/base.py",
>>> line 220, in execute
>>>     output = self.handle(*args, **options)
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/south/management/commands/migrate.py",
>>> line 105, in handle
>>>     ignore_ghosts = ignore_ghosts,
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/south/migration/__init__.py",
>>> line 191, in migrate_app
>>>     success = migrator.migrate_many(target, workplan, database)
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/south/migration/migrators.py",
>>> line 221, in migrate_many
>>>     result = migrator.__class__.migrate_many(migrator, target,
>>> migrations,
>>> database)
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/south/migration/migrators.py",
>>> line 292, in migrate_many
>>>     result = self.migrate(migration, database)
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/south/migration/migrators.py",
>>> line 125, in migrate
>>>     result = self.run(migration)
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/south/migration/migrators.py",
>>> line 99, in run
>>>     return self.run_migration(migration)
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/south/migration/migrators.py",
>>> line 82, in run_migration
>>>     south.db.db.execute_deferred_sql()
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/south/db/generic.py",
>>> line 184, in execute_deferred_sql
>>>     self.execute(sql)
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/south/db/generic.py",
>>> line 150, in execute
>>>     cursor.execute(sql, params)
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/django/db/backends/util.py",
>>> line 34, in execute
>>>     return self.cursor.execute(sql, params)
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/django/db/backends/mysql/base.py",
>>> line 86, in execute
>>>     return self.cursor.execute(query, args)
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/MySQLdb/cursors.py",
>>> line 173, in execute
>>>     self.errorhandler(self, exc, value)
>>>   File
>>>
>>> "/home/jledbetter/Envs/lernanta/lib/python2.6/site-packages/MySQLdb/connections.py",
>>> line 36, in defaulterrorhandler
>>>     raise errorclass, errorvalue
>>> _mysql_exceptions.OperationalError: (1005, "Can't create table
>>> 'lernanta.#sql-3d3_a9f' (errno: 150)")
>>>
>>>
>>> Here's how I fixed it -- in case others have this. I switched from mysql
>>> to
>>> sqlite3! Yes, probably about time :) Greg reminded me of its
>>> wonderfulness
>>> in IRC today and this seemed the perfect time to update my local
>>> installation too!
>>>
>>> Sqlite3 is great for development and I've been using it elsewhere but was
>>> using mysql for local development on Lernanta. Why? Mostly because I was
>>> more familiar with mysql and it came that way :)
>>>
>>> To switch to sqlite3, in your settings_local.py file put this:
>>>
>>> DATABASES = {
>>>
>>>     'default': {
>>>         'NAME': '/home/jledbetter/projects/lernanta/lernanta.db',
>>>         'ENGINE': 'django.db.backends.sqlite3',
>>>     }
>>>
>>> }
>>>
>>> where your database information is. Of course, update the path to the
>>> file
>>> (the database "name") to be where the file is that you're using. The
>>> engine
>>> switches from msyql to sqlite3. The rest of the stuff isn't needed, I
>>> don't
>>> think. You don't need the mysql version but feel free to just comment it
>>> out
>>> in case you want to switch back or there are problems.
>>>
>>> Maybe we should have the default in settings_local.dist.py to be sqlite3?
>>> Would save us a bit of mysql documentation/headache.
>>>
>>> Jessica
>>>
>>>
>>> --
>>> Jessica Ledbetter
>>> http://jessicaledbetter.com
>>>
>>>
>>> _______________________________________________
>>> p2pu-dev mailing list
>>> p2pu-dev at lists.p2pu.org
>>> http://lists.p2pu.org/mailman/listinfo/p2pu-dev
>>>
>>>
>>> _______________________________________________
>>> p2pu-dev mailing list
>>> p2pu-dev at lists.p2pu.org
>>> http://lists.p2pu.org/mailman/listinfo/p2pu-dev
>>>
>>>
>> _______________________________________________
>> p2pu-dev mailing list
>> p2pu-dev at lists.p2pu.org
>> http://lists.p2pu.org/mailman/listinfo/p2pu-dev
>>
>
>
>
> --
> Jessica Ledbetter
> http://jessicaledbetter.com
>
>
>
> _______________________________________________
> p2pu-dev mailing list
> p2pu-dev at lists.p2pu.org
> http://lists.p2pu.org/mailman/listinfo/p2pu-dev
>
>


More information about the p2pu-dev mailing list