Flask and SQLAlchemy explained

Awesome explanation of SQLAlchemy with examples and comparison to Django by Armin Ronacher: SQLAlchemy and You Flask-SQLAlchemy module Flask-SQLAlchemy is an extension for Flask that adds support for SQLAlchemy to your application. How to add SQLAlchemy to Flask application: from flask import Flask from flask_sqlalchemy import SQLAlchemy app = Flask(__name__) # configuration of the DB is read from flask configuration storage app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:////tmp/test.db' # here we define db object that keeps track of sql interactions db = SQLAlchemy(app) Now we are ready to define tables and objects using predefined db....

January 11, 2018 · SergeM

learning sqlite

create table named t3 (id, value). id is integer. value is text sqlite> create table if not exists t3( id int , value varchar, primary key(id)); adding two “rows” sqlite> insert into t3 (id, value) values (1, 'a'); sqlite> insert into t3 (id, value) values (2, 'b'); display results sqlite> select *  from t3; 1|a 2|b update id=1 if exists, insert otherwise (id=1 exists) sqlite> insert or replace into t3 (id,value) values (1,‘c’ ); sqlite> select * from t3; 2|b 1|c...

February 9, 2014 · SergeM