예제 #1
0
from test import db, Human
""" ###CREATE
db.create_all()
human1 = Human('Arin', 25)

human2 = Human('Mahmut',32)

human3=Human('Hayriye',20)


db.session.add_all([human1,human2,human3])
db.session.commit()

print(human1.id)
print(human2.id)

### """

### READ
""" 
humanx = Human.query.get(2)
print(humanx.name) """

##UPDATE
""" first_human = Human.query.get(1)
first_human.age=55

db.session.add(first_human)
db.session.commit()

print(first_human) """
예제 #2
0
    # the Questions object can now be iterated over. (also allows us to convert to a dict() )
    def __iter__(self):
        yield 'id', self.id
        yield 'title', self.title
        yield 'text', self.text
        yield 'register_date', str(self.register_date)
        yield 'engineer', self.engineer
        yield 'closed', self.closed
        yield 'user_id', self.user_id
        yield 'ups', self.ups
        yield 'downs', self.downs
        yield 'tags', self.tags


# Initializes the database
db.create_all()


# Returns True if user exists
def questionExists(id):
    return Question.query.filter_by(id=id).first() is not None


# Returns True if user is created
def createQuestion(title, text, engineer, user_id, tags=""):
    try:
        # Create the new Question
        question = Question(title=title,
                            text=text,
                            engineer=engineer,
                            closed=False,
예제 #3
0
from test import db
db.create_all()
예제 #4
0
 def setUp(self):
     db.create_all()
     self.seeder = Seeder(app, db)
예제 #5
0
from test import db, Human
"""
db.create_all()
human1 = Human('kubs',28)
human2 = Human('hizs',34)

db.session.add_all([human1,human2])
db.session.commit()

print(human1.id)
print(human2.id)
"""
""" READ
all_human = Human.query.all()
humin = Human.query.get(2)
print(all_human)
print(humin)"""
""" UPDATE
hum = Human.query.get(1)
hum.age = 29
db.session.add(hum)
db.session.commit()

print(hum)"""
"""SİLME
hums = Human.query.get(1)
db.session.delete(hums)
db.session.commit()
"""