I have been following everything in this tutorial for Postgres:https://realpython.com/blog/python/flask-by-example-part-2-postgres-sqlalchemy-and-alembic/
And I have been getting the following error. I don't understand why my system keeps on choosing to use SQLite when I had specifically set up everything for using Postgres.
(table.description, column.name, ce.args[0])
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/util/compat.py", line 202, in raise_from_cause
reraise(type(exception), exception, tb=exc_tb, cause=cause)
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py", line 2329, in visit_create_table
and not first_pk)
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py", line 242, in process
return obj._compiler_dispatch(self, **kwargs)
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/sql/visitors.py", line 81, in _compiler_dispatch
return meth(self, **kw)
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py", line 2360, in visit_create_column
first_pk=first_pk
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/dialects/sqlite/base.py", line 865, in get_column_specification
column.type, type_expression=column)
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/sql/compiler.py", line 290, in process
return type_._compiler_dispatch(self, **kw)
File "/usr/local/lib/python2.7/site-packages/sqlalchemy/sql/visitors.py", line 79, in _compiler_dispatch
raise exc.UnsupportedCompilationError(visitor, cls)
sqlalchemy.exc.CompileError: (in table 'results', column 'result_all'): Compiler <sqlalchemy.dialects.sqlite.base.SQLiteTypeCompiler object at 0x1110e4090> can't render element of type <class 'sqlalchemy.sql.sqltypes.JSON'>
This is what I have for views.py
from flask import render_template
#from app import app
from flask import Flask
from flask import Flask, flash, redirect, render_template, request, session, abort
from flask_sqlalchemy import SQLAlchemy
import os
app = Flask(__name__)
app.config.from_pyfile('../config.py')
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
from models import Result
And this is my Config.py
import os
basedir = os.path.abspath(os.path.dirname(__file__))
class Config(object):
DEBUG = False
TESTING = False
CSRF_ENABLED = True
SECRET_KEY = 'this-really-needs-to-be-changed'
SQLALCHEMY_DATABASE_URI = os.environ['DATABASE_URL']
class ProductionConfig(Config):
DEBUG = False
class StagingConfig(Config):
DEVELOPMENT = True
DEBUG = True
class DevelopmentConfig(Config):
DEVELOPMENT = True
DEBUG = True
class TestingConfig(Config):
TESTING = True
echo $DATABASE_URL
in shell?.. – Vao Tsun Nov 30 at 8:28