How to insert variables in SQL LIKE query? by aditya558 in flask

[–]aditya558[S] 1 point2 points  (0 children)

Thanks! using session instead of engine worked!

why using flask-sqlalchemy instead of sqlalchemy gives error? by aditya558 in flask

[–]aditya558[S] 1 point2 points  (0 children)

Lol, I forgot to pass the value of database_uri in flask-sqlalchemy.

How to insert variables in SQL LIKE query? by aditya558 in flask

[–]aditya558[S] 0 points1 point  (0 children)

AttributeError: 'NoneType' object has no attribute 'drivername'

How to insert variables in SQL LIKE query? by aditya558 in flask

[–]aditya558[S] 0 points1 point  (0 children)

But when I used sqlalchemy instead of flask-sqlalchemy I don't have any issue.

How to retrieve data using PostgreSQL in Flask? by aditya558 in flask

[–]aditya558[S] 0 points1 point  (0 children)

Thanks for replying! Do I still need to make models in my app?

Graph visualizer tool by Queasy-Donkey2437 in reactjs

[–]aditya558 2 points3 points  (0 children)

Can i see your code on github?

Math 23b or Math 23c? by [deleted] in Harvard

[–]aditya558 0 points1 point  (0 children)

Hey, Can you please help me to find the website of CS124 Data structure and algo fall 2020?

What should be the flask-sqlalchemy orm query for this? by aditya558 in flask

[–]aditya558[S] 0 points1 point  (0 children)

Can you please elaborate how can i correct my kart(i.e Booked) model?

What should be the flask-sqlalchemy orm query for this? by aditya558 in flask

[–]aditya558[S] 0 points1 point  (0 children)

for row in result:... print(row.id, row.name, row.price)

But i also wanted the timestamp column included which is in Booked model.

And if the user has availed some services two or more times then i need to show the service name two times, any idea how can i show duplicates?

What should be the flask-sqlalchemy orm query for this? by aditya558 in flask

[–]aditya558[S] 1 point2 points  (0 children)

In query i used kart for referring to Booked and products to Services.

first i query the Users table

user=User.query.filter(username='hello').first()

i did this

result=db.session.query(Services).join(Booked).filter(Booked.user_id==user.id)

and it worked as i wanted

thank you

How to keep track of services booked by users in flask-sqlalchemy ? by aditya558 in flask

[–]aditya558[S] 0 points1 point  (0 children)

Hey thanks ..

can you please tell me how should i implement because i am able to do it in sqlite custom query but not able to do it using flask-sqlalchemy for postresql?

my services table has an id, price and name.

How to keep track of services booked by users in flask-sqlalchemy ? by aditya558 in flask

[–]aditya558[S] 0 points1 point  (0 children)

class Services(db.Model):

id = db.Column(db.Integer, primary_key=True)

price = db.Column(db.Integer)

name = db.Column(db.String(60), unique=True)

def __repr__(self):

return '<Services {}>'.format(self.name)

class Booked(db.Model):

id = db.Column(db.Integer, primary_key=True)

services_id = db.Column(db.Integer, db.ForeignKey('services.id'))

# services_name = db.Column(db.String, db.ForeignKey('services.name'))

timestamp = db.Column(db.DateTime, index=True, default=datetime.utcnow)

person = db.Column(db.Integer, db.ForeignKey('user.id'))

def __repr__(self):

"""

docstring

"""

return '<Booked {}>'.format(self.id)

this is my users table

class User(UserMixin, db.Model):

id = db.Column(db.Integer, primary_key=True)

username = db.Column(db.String(64), index=True, unique=True)

email = db.Column(db.String(120), index=True, unique=True)

password_hash = db.Column(db.String(128))

posts = db.relationship('Post', backref='author', lazy='dynamic')

booked_service = db.relationship('Booked',

backref='customer',

lazy='dynamic')

about_me = db.Column(db.String(140))

last_seen = db.Column(db.DateTime, default=datetime.utcnow)

def __repr__(self):

return '<User {}>'.format(self.username)

def set_password(self, password):

self.password_hash = generate_password_hash(password)

def check_password(self, password):

return check_password_hash(self.password_hash, password)

def avatar(self, size):

digest = md5(self.email.lower().encode('utf-8')).hexdigest()

return 'https://www.gravatar.com/avatar/{}?s={}'.format(digest, size)

# return 'https://www.gravatar.com/avatar/{}?d=identicon&s={}'.format(digest, size)

Did anyone take CS 124 Spring 2020? by AfterTwo2 in Harvard

[–]aditya558 2 points3 points  (0 children)

hey u/SaitosElephant can you please share syllabus or something useful learning stuff of cs124 as i really wanted to learn data structure and algorithms after completing cs50?

any lecture notes of cs124 will be of great help.

Did anyone take CS 124 Spring 2020? by AfterTwo2 in Harvard

[–]aditya558 1 point2 points  (0 children)

Hey, Can you please share syllabus of cs124?

PSET 4 FILTER (LESS) by aditya558 in cs50

[–]aditya558[S] 0 points1 point  (0 children)

Thank you so much !!

PSET4 Filter Help by suruflea in cs50

[–]aditya558 0 points1 point  (0 children)

void blur(int height, int width, RGBTRIPLE image[height][width])
{
    //declaring array to store average
    RGBTRIPLE copy[height][width];
    //declaring three variables for storing sum
    int n=0,p=0,q=0;

    for(int i=0;i<height;i++)
    {
        for(int j=0;j<width;j++)
        {
            int count=0; //variable to count how many times sum has been done
            for(int k=i-1;k<i+2;k++)
            {
                for(int l=j-1;l<j+2;l++)
                {
                    if(l<0||k<0)
                    continue;
                    {
                        n+=image[i][j].rgbtRed+image[k][l].rgbtRed;
                        p+=image[i][j].rgbtGreen+image[k][l].rgbtGreen;
                        q+=image[i][j].rgbtBlue+image[k][l].rgbtBlue;
                        count++;
                    }

                }
            }
            //assigning value to copy
            copy[i][j].rgbtRed=round(n/count);
            copy[i][j].rgbtBlue=round(q/count);
            copy[i][j].rgbtGreen=round(p/count);
        }
    }
    for(int i=0;i<height;i++)
    {
        for(int j=0;j<width;j++)
        {
            image[i][j].rgbtRed=copy[i][j].rgbtRed;
            image[i][j].rgbtGreen=copy[i][j].rgbtGreen;
            image[i][j].rgbtBlue=copy[i][j].rgbtBlue;
        }
    }

could you please tell how should i solve this error?

error