6

17 comments

[–] curious [OP] 0 points (+0|-0)

Arrr. Spoke too soon! Running ./migrate.py is throwing up the following. I'm embarrassing myself here.

Database connection error? Any ideas @E-werd?

Starting migrations
Migrate "001_initial"
Migration failed: 001_initial
Traceback (most recent call last):
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee.py", line 2949, in execute_sql
    cursor.execute(sql, params or ())
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/MySQLdb/cursors.py", line 312, in _query
    db.query(q)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/MySQLdb/connections.py", line 224, in query
    _mysql.connection.query(self, query)
MySQLdb._exceptions.OperationalError: (1101, "BLOB, TEXT, GEOMETRY or JSON column 'sidebar' can't have a default value")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee_migrate/router.py", line 154, in run_one
    migrator.run()
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee_migrate/migrator.py", line 131, in run
    op()
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee.py", line 6296, in create_table
    cls._schema.create_all(safe, **options)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee.py", line 5456, in create_all
    self.create_table(safe, **table_options)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee.py", line 5311, in create_table
    self.database.execute(self._create_table(safe=safe, **options))
  File "../app/models.py", line 64, in peewee_count_queries
    return dex(*args, **kwargs)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee.py", line 2962, in execute
    return self.execute_sql(sql, params, commit=commit)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee.py", line 2956, in execute_sql
    self.commit()
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee.py", line 2732, in __exit__
    reraise(new_type, new_type(*exc_args), traceback)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee.py", line 183, in reraise
    raise value.with_traceback(tb)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee.py", line 2949, in execute_sql
    cursor.execute(sql, params or ())
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/MySQLdb/cursors.py", line 312, in _query
    db.query(q)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/MySQLdb/connections.py", line 224, in query
    _mysql.connection.query(self, query)
peewee.OperationalError: (1101, "BLOB, TEXT, GEOMETRY or JSON column 'sidebar' can't have a default value")
Traceback (most recent call last):
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee.py", line 2949, in execute_sql
    cursor.execute(sql, params or ())
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/MySQLdb/cursors.py", line 312, in _query
    db.query(q)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/MySQLdb/connections.py", line 224, in query
    _mysql.connection.query(self, query)
MySQLdb._exceptions.OperationalError: (1101, "BLOB, TEXT, GEOMETRY or JSON column 'sidebar' can't have a default value")

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./migrate.py", line 25, in <module>
    router.run()
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee_migrate/router.py", line 182, in run
    self.run_one(mname, migrator, fake=fake, force=fake)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee_migrate/router.py", line 154, in run_one
    migrator.run()
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee_migrate/migrator.py", line 131, in run
    op()
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee.py", line 6296, in create_table
    cls._schema.create_all(safe, **options)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee.py", line 5456, in create_all
    self.create_table(safe, **table_options)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee.py", line 5311, in create_table
    self.database.execute(self._create_table(safe=safe, **options))
  File "../app/models.py", line 64, in peewee_count_queries
    return dex(*args, **kwargs)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee.py", line 2962, in execute
    return self.execute_sql(sql, params, commit=commit)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee.py", line 2956, in execute_sql
    self.commit()
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee.py", line 2732, in __exit__
    reraise(new_type, new_type(*exc_args), traceback)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee.py", line 183, in reraise
    raise value.with_traceback(tb)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/peewee.py", line 2949, in execute_sql
    cursor.execute(sql, params or ())
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/MySQLdb/cursors.py", line 206, in execute
    res = self._query(query)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/MySQLdb/cursors.py", line 312, in _query
    db.query(q)
  File "/home/app/.pyenv/versions/app/lib/python3.5/site-packages/MySQLdb/connections.py", line 224, in query
    _mysql.connection.query(self, query)
peewee.OperationalError: (1101, "BLOB, TEXT, GEOMETRY or JSON column 'sidebar' can't have a default value")
(app) app@DESKTOP-K7K63GA:~/throat/scripts$
[–] E-werd 1 points (+1|-0)

Check on your config.py settings. Reference one of the newer guides to see how it should be.

[–] curious [OP] 0 points (+0|-0) Edited

This is how the config.py file looks like (truncated the bottom parts of the file)

What I have done is use the following format as was in the config.py file.

DATABASE_URL = 'mysql://**debian-sys-maint**:**5oCNi3MRmSXRxJFI**@localhost/throat'

DBUSER in this case is debian-sys-maint

PASSWORD is 5oCNi3MRmSXRxJFI

Not sure if I'm doing this right. Since the config.py is the latest version, thought of keeping it this way to connect to the database (based on the example.config.py file).

My config.py file btw.

""" This is the config file. Pretty obvious, right? """
import os

# Site title
LEMA = "Throat: Open discussion ;D"
# Copyright notice, used in the footer
COPY = "2016 Throat. All Rights Reserved."

# Database connection information
DATABASE_URL = 'mysql://debian-sys-maint:5oCNi3MRmSXRxJFI@localhost/throat'

# Method used to memoize stuff. Change to 'redis' if you use Redis
CACHE_TYPE = 'simple'

# Only used if CACHE_TYPE is 'redis'.
CACHE_REDIS_HOST = '127.0.0.1'
CACHE_REDIS_PORT = 6379
CACHE_REDIS_DB = 5
....
[–] E-werd 1 points (+1|-0) Edited

OK, it's your DATABASE_URL line. That was changed when we started supporting multiple database types. The new format, given your information...

DATABASE = {
    'host': 'localhost',
    'name': 'throat',
    'engine': 'MySQLDatabase',
    'user': 'debian-sys-maint',
    'password': '5oCNi3MRmSXRxJFI',
}

EDIT: See this guide that covers all the database types: https://pastebin.com/zFfLuMV6

The options for "engine" are: PostgresqlDatabase, MySQLDatabase, SqliteDatabase

I'm mostly putting this info here in case anybody looks in a search engine, it's outside of your scope.