This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
from flask_sqlalchemy import SQLAlchemy | |
import logging | |
app = Flask(__name__) | |
app.config['SQLALCHEMY_DATABASE_URI'] ='postgresql://<username>:password@localhost/<db-name>' | |
logging.basicConfig() | |
logging.getLogger('sqlalchemy.engine').setLevel(logging.INFO) | |
app.config['FLASK_ENV'] = 'development' | |
db = SQLAlchemy(app) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE results( | |
id SERIAL PRIMARY KEY, | |
student_id INT NOT NULL, | |
course VARCHAR NOT NULL, | |
score INT NOT NULL, | |
course_end_date DATE, | |
UNIQUE(student_id, course) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TABLE results( | |
id SERIAL PRIMARY KEY, | |
student_id INT NOT NULL, | |
subject VARCHAR NOT NULL, | |
score INT NOT NULL, | |
UNIQUE(student_id, subject) | |
) | |
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Request{ | |
tableName = "request"; | |
insertColumns =["body","image","user_id"]; | |
retrievalString = "body, image, user_id AS userId"; | |
create(*params){ | |
const valueArr = []; | |
self.insertColumns.forEach((element, index) => { | |
valueArr.push(`$${index+1}`); | |
}); | |
const valueString = valueArr.join(',') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function newName(){ | |
alert('Name'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime, timedelta | |
from dateutil.rrule import rrule, WEEKLY, DAILY | |
def get_number_of_weeks(smaller_date, bigger_date): | |
return rrule(DAILY, dtstart = smaller_date ,until=bigger_date).count() | |
if __name__ == '__main__': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { expect } from 'chai'; | |
import supertest from 'supertest'; | |
import app from '../app'; | |
const request = supertest(app); | |
describe('POST /api/v1/articles', ()=> { | |
describe('if the request is valid', () => { | |
describe('request body', ()=> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
asdfgh |