Thanks you for being so helpful and elaborate @E-werd. Please answer at your leisure time as I've taking too much of your time.
Here's how my complete config.py file looks now.
""" 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 configuration
##
DATABASE = {
'host': 'localhost',
'name': 'throat',
'engine': 'MySQLDatabase',
'user': 'debian-sys-maint',
'password': '5oCNi3MRmSXRxJFI',
}
# 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
# The Redis that we use for SocketIO. This must be the same for all instances
SOCKETIO_REDIS_URL = 'redis://127.0.0.1:6379/1'
# Secret key used to encrypt session cookies. CHANGE THIS
SECRET_KEY = 'yS\x1c\x88\xd7\xb5\xb0\xdc\t:kO\r\xf0D{"Y\x1f\xbc^\xad'
# wtforms settings. Set to False to disable CSRF
WTF_CSRF_ENABLED = True
WTF_CSRF_SECRET_KEY = SECRET_KEY
# Sengrid API key, only used to send password recovery emails
SENDGRID_API_KEY = "put it here"
SENDGRID_DEFAULT_FROM = "[email protected]"
# This is the path thumbnails will be stored on
THUMBNAILS = "./thumbs"
# This is the domain where the thumbnails are hosted on. Can be an absolute path too.
THUMBNAIL_HOST = "https://foo.bar/"
# THUMBNAIL_HOST = "/static/thumbnails"
# Same as above but for file storage (Used for user and sub file uploads)
STORAGE = "./stor"
STORAGE_HOST = "https://i.foo.bar/"
# SID of changelog sub (used to display last changelog entry on the sidebar)
# Leave empty to disable changelogs
CHANGELOG_SUB = ''
# Only for debugging and testing. Disable both in production
DEBUG = True
TESTING = True # This makes all the captchas valid
# Max content-length accepted by the server
MAX_CONTENT_LENGTH = (1024 * 1024) * 10 # 10MB limit
# Prefix for subs. Must always start with /.
SUB_PREFIX = "/s"
I've also removed the following line.
DATABASE_URL = 'mysql://debian-sys-maint:5oCNi3MRmSXRxJFI@localhost/throat'
Next, I run the following.
app@DESKTOP-K7K63GA:~/throat$ scripts/migrate.py
But again the following error is produced.
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 "scripts/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")
So close, yet so far. Almost there, but NOT yet!
So the migrate.py file is ONLY for migrating from an existing installation of phuks to the latest code base and NOT for a fresh installation of Phuks.
The installation steps will have already created a throat database for you. However, this is not the database you need. You need the database of your existing Phuks installation.
For this, create a copy of your existing Phuks database and name it say, throat2. Export it as, say throat2.sql and create a copy of your Phuks database. You'll use this sql file to create a new database where you want to install phuks.
Follow the steps in this article to copy and export sql databases.
Once you've created a throat2 database, import the throat2 database using the throat2.sql file to the database throat2.
Once you've imported the database, on the config.py file, replace throat with throat2 since we will be using the throat2 database now.
DATABASE = {
'host': 'localhost',
'name': 'throat2',
'engine': 'MySQLDatabase',
'user': 'debian-sys-maint',
'password': '5oCNi3MRmSXRxJFI',
}
Once done, run the ./migrate.py script and you'll have the following output.
Starting migrations
Migrate "001_initial"
Done 001_initial
Migrate "002_subcreation"
Done 002_subcreation
Migrate "003_submod"
Done 003_submod
Migrate "004_subban"
Done 004_subban
Migrate "005_banreasonlength"
change_column ('sub_ban', 'reason', <CharField: SubBan.reason>)
Done 005_banreasonlength
Migrate "006_comment_history"
Done 006_comment_history
After the above commands are executed type cd..
Next, I type nano wsgi.py
and the file is opened.
#!/usr/bin/env python3
""" From here we start the app in debug mode. """
import eventlet
eventlet.monkey_patch()
from app import app, socketio # noqa
if __name__ == "__main__":
socketio.run(app, debug=True)
I do nothing with this file and move on to the next step, which is run the following command.
./wsgi.py
The following output is displayed on my terminal .
```
INFO:werkzeug: * Restarting with stat
WARNING:werkzeug: * Debugger is active!
INFO:werkzeug: * Debugger PIN: 336-192-212
(6555) wsgi starting up on http://127.0.0.1:5000
```
I navigate to http://127.0.0.1:5000
but I'm getting the following AttributeError page on the browser. What should I do next @E-werd?
This is what the console shows me.
INFO:werkzeug: * Debugger PIN: 336-192-212
(6555) wsgi starting up on http://127.0.0.1:5000
(6555) accepted ('127.0.0.1', 56636)
DEBUG:peewee:('SELECT `t1`.`nsfw`, `t1`.`content`, `t1`.`pid`, `t1`.`title`, `t1`.`posted`, `t1`.`deleted`, `t1`.`score`, `t1`.`ptype`, `t1`.`thumbnail`, `t1`.`link`, `t2`.`name` AS `user`, `t3`.`name` AS `sub`, `t1`.`flair`, `t1`.`edited`, `t3`.`sid`, `t1`.`comments`, `t2`.`uid`, `t2`.`status` AS `userstatus` FROM `sub_post` AS `t1` LEFT OUTER JOIN `user` AS `t2` ON (`t1`.`uid` = `t2`.`uid`) LEFT OUTER JOIN `sub` AS `t3` ON (`t1`.`sid` = `t3`.`sid`) LEFT OUTER JOIN `site_metadata` AS `t4` ON (`t4`.`key` = %s) WHERE (((`t1`.`deleted` = %s) AND (`t1`.`nsfw` = %s)) AND (`t1`.`sid` = `t4`.`value`)) ORDER BY ((`t1`.`score` * %s) + ((Unix_Timestamp(`t1`.`posted`) - %s) / %s)) DESC LIMIT %s OFFSET %s', ['default', 0, False, 20, 1134028003, 1500, 25, 0])
Traceback (most recent call last):
File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/flask/app.py", line 2449, in wsgi_app
response = self.handle_exception(e)
File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/flask/app.py", line 1866, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/flask/app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/flask/app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/flask/app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/flask/app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/home/app/throat/app/__init__.py", line 148, in index
return home_hot(1)
File "/home/app/throat/app/__init__.py", line 157, in home_hot
'subOfTheDay': misc.getSubOfTheDay(),
File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/flask_caching/__init__.py", line 795, in decorated_function
rv = f(*args, **kwargs)
File "/home/app/throat/app/misc.py", line 696, in getSubOfTheDay
daysub = Sub.select(Sub.sid, Sub.name, Sub.title).order_by(db.random()).get()
File "/home/app/.pyenv/versions/3.5.2/envs/app/lib/python3.5/site-packages/peewee.py", line 439, in __getattr__
return getattr(self.obj, attr)
AttributeError: 'MySQLDatabase' object has no attribute 'random'
127.0.0.1 - - [07/Aug/2019 08:30:31] "GET / HTTP/1.1" 500 26122 0.070092
127.0.0.1 - - [07/Aug/2019 08:30:31] "GET /?__debugger__=yes&cmd=resource&f=style.css HTTP/1.1" 200 6745 0.001529
(6555) accepted ('127.0.0.1', 56638)
(6555) accepted ('127.0.0.1', 56639)
127.0.0.1 - - [07/Aug/2019 08:30:31] "GET /?__debugger__=yes&cmd=resource&f=jquery.js HTTP/1.1" 200 88301 0.000898
127.0.0.1 - - [07/Aug/2019 08:30:31] "GET /?__debugger__=yes&cmd=resource&f=debugger.js HTTP/1.1" 200 6555 0.001083
127.0.0.1 - - [07/Aug/2019 08:30:31] "GET /?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 633 0.000852
127.0.0.1 - - [07/Aug/2019 08:30:31] "GET /?__debugger__=yes&cmd=resource&f=console.png HTTP/1.1" 200 633 0.000714
Stand by on this one.
Ok
I'll have to give it a try again.
Sure. I'll wait.
OK, it's your
DATABASE_URL
line. That was changed when we started supporting multiple database types. The new format, given your information...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.