After having played for a long time with Django, I'm trying a bit of Flask with SQLAlchemy, and I must say I quite like it. However there is something that I don't get:
I have a small Flask / SQLAlchemy app that uses PostgreSQL.
In my __init__.py file I have:
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
app = Flask(__name__
I've read flask-sqlalchemy or sqlalchemy which recommends use of flask-sqlalchemy with flask. I want to follow this approach.
However, I have an existing model written for command line scripts which is based on sqlalchemy's declarative_base, e.g.,
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base() # create sqlalc
When i run the dbManager.create_all() command, it runs with out errors but fails to create the tables. When i delete the database and run the create_all() command, i get the no such database as ##### error which i should get but when the database does exist, nothing happens.
Please can anyone see what i'm doing wrong?
from blogconfig import dbMana
I have connected to a clickhouse db with dbeaver and installed sqlalchemy v1.3.13 and clickhouse-sqlalchemy 0.1.3 for python 3.7.
When I tried to connect with
from sqlalchemy import create_engine
engine_clickhouse = create_engine('clickhouse://use:pass@host:port/db')
Exception: Code: 516, e.display
I'm trying to create a one-to-one relationship in Flask using SqlAlchemy. I followed this previous post and I created the classes like ones below:
__tablename__ = 'image'
image_id = db.Column(db.Integer, primary_key = True)
name = db.Column(db.String(8))
__tablename__ = 'blindmap'
I create a class for working with SQLAlchemy :
self.dbDriver = "mysql";
self.dbHostname = "localhost";
self.dbUsername = "root";
self.dbPassword = "123";
self.dbName = "mydbname";
I would like to declare a base class that all other schema objects
can inherit from, for example:
created_on = db.Column(db.DateTime, default=db.func.now())
updated_on = db.Column(db.DateTime, default=db.func.now(), onupdate=db.func.now())
Then all other schema objects can inherit from it and not have to repeat
I have two tables sharing the same name but located in different databases:
__tablename__ = 'lcn'
__bind_key__ = 'remote'
__tablename__ = 'lcn'
It seems SQLAlchemy doesn't like that. It says:
sqlalchemy.exc.InvalidRequestError: Table 'lcn' is already defined for this MetaData insta
I have a Flask view which uses SQLAlchemy to query and display some blog posts. I am running my app using mod_wsgi. This view works the first time I go to the page, but returns a 500 error next time. The traceback shows the error ProgrammingError: SQLite objects created in a thread can only be used in that same thread. Why am I getting this err
I can't sto re Swedish characters in MySQL by using Flask_SQLAlchemy :( I have tried to find a solution for a week now and I really need help as it feels like I have reached a dead end. I think it could be something wrong with the version compatibilities abong my tools, but I don't hope so! I am trying to build an website using Flask, Flask_SQLAlch