Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
CRUD_Animais_da_Fazenda
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
7
Issues
7
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Hiago Rafael
CRUD_Animais_da_Fazenda
Commits
cacc3e2e
Commit
cacc3e2e
authored
Apr 16, 2026
by
bricioso
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
atualizei o models.py
parent
699db5da
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
5 deletions
+20
-5
models.py
Python/models.py
+20
-5
No files found.
Python/models.py
View file @
cacc3e2e
from
flask_sqlalchemy
import
SQLAlchemy
from
flask_sqlalchemy
import
SQLAlchemy
db
=
SQLAlchemy
()
db
=
SQLAlchemy
()
class
Pessoa
(
db
.
Model
):
__tablename__
=
'pessoas'
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
nome
=
db
.
Column
(
db
.
String
(
100
),
nullable
=
False
)
idade
=
db
.
Column
(
db
.
Integer
)
data_nascimento
=
db
.
Column
(
db
.
String
(
20
))
# Campo do formulário do Ian
sexo
=
db
.
Column
(
db
.
String
(
1
))
# M ou F
peso
=
db
.
Column
(
db
.
Float
)
# Campo usado no 'Editar'
# Isso permite ver quais animais pertencem a essa pessoa/fazenda
animais
=
db
.
relationship
(
'Animal'
,
backref
=
'dono'
,
lazy
=
True
)
class
Animal
(
db
.
Model
):
class
Animal
(
db
.
Model
):
__tablename__
=
'animais'
__tablename__
=
'animais'
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
id
=
db
.
Column
(
db
.
Integer
,
primary_key
=
True
)
nome
=
db
.
Column
(
db
.
String
(
100
),
nullable
=
False
)
nome
=
db
.
Column
(
db
.
String
(
100
),
nullable
=
False
)
especie
=
db
.
Column
(
db
.
String
(
50
),
nullable
=
False
)
# Ex: Suíno
especie
=
db
.
Column
(
db
.
String
(
100
),
nullable
=
False
)
preco
=
db
.
Column
(
db
.
Float
,
nullable
=
False
)
# Preço de venda
idade
=
db
.
Column
(
db
.
Integer
,
nullable
=
False
)
fazenda
=
db
.
Column
(
db
.
String
(
100
),
nullable
=
False
)
# Quem está vendendo
peso
=
db
.
Column
(
db
.
Float
,
nullable
=
False
)
peso
=
db
.
Column
(
db
.
Float
,
nullable
=
False
)
\ No newline at end of file
# Conecta o animal a uma fazenda/pessoa específica
pessoa_id
=
db
.
Column
(
db
.
Integer
,
db
.
ForeignKey
(
'pessoas.id'
),
nullable
=
True
)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment