Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'SQLAlchemy' object has no attribute 'model' #31

Closed
Xnsam opened this issue Jan 21, 2019 · 8 comments
Closed

AttributeError: 'SQLAlchemy' object has no attribute 'model' #31

Xnsam opened this issue Jan 21, 2019 · 8 comments

Comments

@Xnsam
Copy link

Xnsam commented Jan 21, 2019

Hi,

I was try to use package structure in the project with small changes here and there. When i do python run.py I get the following errors.

only folder names are different and some code. I tried to look out the answers in stack overflow but could not understand a thing as i am noobie.

> /home/#####/anaconda2/envs/py3/lib/python3.6/site-packages/flask_sqlalchemy/__init__.py:794: FSADeprecationWarning: SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and will be disabled by default in the future.  Set it to True or False to suppress this warning.
>   'SQLALCHEMY_TRACK_MODIFICATIONS adds significant overhead and '
> Traceback (most recent call last):
>   File "run.py", line 3, in <module>
>     from vf import app
>   File "/home/####/Documents/versatile/vf/__init__.py", line 12, in <module>
>     class User(db.model):
> AttributeError: 'SQLAlchemy' object has no attribute 'model'

Please kindly help me out?

@OG0mez
Copy link

OG0mez commented Feb 13, 2019

model starts with capital M
class User(db.Model)

@Salman-AIi
Copy link

Even Capital M dosent work for me ;(((

@gregoryYentz
Copy link

gregoryYentz commented Dec 9, 2019

Salman-Ali, I was having your same problem.
Make sure you have capital 'M', but the issue was with my def repr(self) functions.
I changed mine to:

def __repr__(self):
		value = "Post({}, {})".format(self.title, self.post)
		return value

for both User and Post classes.
This worked for me, hope it works for you.

@JaceBillingsley
Copy link

_id = db.column("id", db.integer, primary_key=True)

AttributeError: 'SQLAlchemy' object has no attribute 'integer'

@ituitis20-bekture18
Copy link

ituitis20-bekture18 commented Nov 12, 2020

_id = db.column("id", db.integer, primary_key=True)

AttributeError: 'SQLAlchemy' object has no attribute 'integer'

BreezeCodez,
Make sure you have capital 'I' in your integer. So it should be 'Integer' instead of 'integer'

@ojpau2kool
Copy link

mine is in caps but its still giving the same error message...
here is the code i'm trying to create a database

from flask import Flask, render_template, request
from flask_sqlalchemy import SQLAlchemy

app = Flask(name)
app.config['SQLALCHEMY_DATABASE_URI'] = 'SQLITE:///test.db'

app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

db = SQLAlchemy(app)

class Clients(db.Model):
tablename = 'clients'
id = db.Column("id", db.Integer, primary_key=True)
client_name = db.Column(db.String(200))
client_address = db.Column(db.String(200))
email = db.Column(db.String(200))
phone_number = db.Column(db.Interger(20))
appointment_description = db.Text(db.String(1000))
appointment_time = db.Column(db.Interger(10))
appointment_date = db.Column(db.Interger(10))

def __init__(self, client_name, client_address, email, phone_number, appointment_description, appointment_time, appointment_date):
   self.client_name = client_name
   self.client_address = client_address
   self.email = email
   self.phone_number = phone_number
   self.appointment_description = appointment_description
   self.appointment_time = appointment_time
   self.appointment_date = appointment_date

it keeps returning this error message
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\YY\Desktop\PythonFiles\Project 1\framework.py", line 12, in
class Clients(db.Model):
File "C:\Users\YY\Desktop\PythonFiles\Project 1\framework.py", line 17, in Clients
phone_number = db.Column(db.Interger(20))
AttributeError: 'SQLAlchemy' object has no attribute 'Interger'

@zobisco
Copy link

zobisco commented Jul 8, 2021

@ojpau2kool you seem to have written 'Interger' instead of 'Integer'

@mon842
Copy link

mon842 commented Oct 23, 2021

AttributeError: 'SQLAlchemy' object has no attribute 'set_character_set'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants