I've upgraded my app engine to flexible and am now refactoring code. I haven't worked with Flask besides in standard and haven't used SQLAlchemy. I've set up my databases and have had valid, functioning connections before in standard environment. I'm now trying to execute a simple SQL in Python3 flexible environment:
SELECT id, latitude, longitude FROM weatherData
I now have a valid connection to the database through the following:
app = Flask(__name__)
app.config['WEATHER_DATABASE_URI'] = os.environ['WEATHER_DATABASE_URI']
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
The respective environment variables are in my app.yaml file.
I understand that SQLAlchemy uses ORMs but in all the examples I've seen they've created a class as 'buffer' between the client and database to firstly create the table, and then perform CRUD operations. Eg.
engine = create_engine('sqlite:///student.db', echo=True)
Base = declarative_base()
class Student(Base):
""""""
__tablename__ = "student"
id = Column(Integer, primary_key=True)
username = Column(String)
firstname = Column(String)
lastname = Column(String)
university = Column(String)
#----------------------------------------------------------------------
def __init__(self, username, firstname, lastname, university):
""""""
self.username = username
self.firstname = firstname
self.lastname = lastname
self.university = university
# create tables
Base.metadata.create_all(engine)
I notice that in this case they're using engine which doesn't seem relevant to me. In short, how can I perform the aforementioned SQL query?
Thanks :)