예제 #1
0
def main():
    ATM(
        menu,
        Accounts(
            Table(
                File('accounts.txt')
            )
        ),
        History(
            Table(
                File('transactions.txt')
            )
        )
    ).start()
예제 #2
0
def table_view():
    s = bottle.request.environ.get('beaker.session')
    t = s.get('table', None)
    if t is None:
        t = Table(5, 5, 7)
        s['table'] = t
        s.save()
    return dict(table=t)
예제 #3
0
def click():
    s = bottle.request.environ.get('beaker.session')
    x = int(request.forms.get('size_x'))
    y = int(request.forms.get('size_y'))
    num = int(request.forms.get('num_mines'))
    t = Table(num, x, y)
    s['table'] = t
    s.save()
    redirect('/game')
예제 #4
0
파일: main.py 프로젝트: Snd18/GENBOT_public
def tablename_intent(req):
    # get model by username
    data = getUserData(req.user)
    # create table and add to user data
    data.db.table = table.Table(req.tablename, '', None)
    # generate response
    text = "Ok, saved!\nNow I need the csv url of '" + req.tablename + "' table."
    r = response.Response(text, None, [], [], None)
    res = r.response
    return res
예제 #5
0
def create_tables(num_tables, num_people):
    """Create 'num_tables' Table objects that can hold 'num_people' on each
    Table - commit to database."""

    for i in range(num_tables):

        current = Table(people_count=num_people)

        db.session.add(current)

    db.session.commit()
예제 #6
0
파일: main.py 프로젝트: mindfox/tables
    def handle(self):
        p = float(self.request.get("p"))
        SEATS_PER_TABLE = 10
        for price in [p]:
            t = Table(price=btc2satoshi(price))
            t.put()
            for n in xrange(SEATS_PER_TABLE):
                seat = Seat(table=t,
                            number=n,
                            purchase_addr=new_address(),
                            state=EMPTY)
                seat.table = t
                seat.put()
                from time import sleep
                sleep(1)

        return {"success": True}
예제 #7
0
def register():
    form = RegisterForm(request.form)
    if form.validate_on_submit():
        gmail.mail(form.email.data, form.username.data)
        newUser = Table(username=form.username.data,
                        email=form.email.data,
                        password=form.password.data,
                        phoneNo=form.number.data)

        try:
            db.session.add(newUser)
            db.session.commit()
            flash(
                "You are Registered Server Side. Please check your mail for further instructions."
            )

            return redirect('/login')
        except:
            return 'error saving name'

    return render_template('register.html', form=form)
예제 #8
0
def create_tables(event_id):
    '''create tables'''
    if is_not_logged_in():
        return redirect('/')

    # retrieve values from the form
    table_name = request.form['table-name']

    max_seats = int(request.form['max-seats'])

    event_id = event_id

    # add the table to the database
    table = Table(event_id=event_id,
                  table_name=table_name,
                  max_seats=max_seats)

    db.session.add(table)
    db.session.commit()

    return redirect('/event={}/event-info'.format(event_id))
예제 #9
0
 def endElement(self, tag):
     if tag == "o:Table" and self.current_table is not None:
         if "code" in self.current_table.keys():
             t = Table()
             for key, val in self.current_table.items():
                 t.__setattr__(key, val)
             self.tables.append(t)
         self.current_table = None
         self.table_map[t.id] = t
     elif tag == "o:Column":
         if "name" in self.current_column.keys():
             c = Column()
             for key, val in self.current_column.items():
                 if key == 'col_type':
                     c.col_type = PdmColumnType[val.upper()]
                 else:
                     c.__setattr__(key, val)
             self.current_table['columns'].append(c)
         self.current_column = None
     elif tag == "a:Name":
         self.current_attr = None
     elif tag == "a:Code":
         self.current_attr = None
     elif tag == "a:DataType":
         self.current_attr = None
     elif tag == "a:Comment":
         self.current_attr = None
     elif tag == "o:Reference" and 'child' in self.current_ref.keys(
     ) and 'parent' in self.current_ref.keys():
         if self.current_ref['child'] not in self.refs.keys():
             self.refs[self.current_ref['child']] = []
         ref = self.refs[self.current_ref['child']]
         ref.append(self.current_ref['parent'])
         self.current_ref = None
     elif self.current_ref is not None and tag == "c:ParentTable":
         self.current_ref['parent'] = self.current_parent_table
         self.current_parent_table = None
     elif self.current_ref is not None and tag == "c:ChildTable":
         self.current_ref['child'] = self.current_child_table
         self.current_child_table = None
예제 #10
0
파일: tests.py 프로젝트: bopopescu/Kpo
 def test_table(self):
     u = Table(id=1, size=3, time1=datetime.datetime(2005, 7, 14, 12, 30))
     db.session.add(u)
     db.session.commit()
예제 #11
0
tableList = []

for i, r in dataFrame.iterrows():
    name = r['name']
    dataType = r['type']
    notNull = r['not null']
    unique = r['unique']
    composite = r['composite']
    default = r['default']

    if pd.isna(name):
        continue

    if dataType == 'TABLE':
        if isOk:
            table = Table(name=tableName, columns=columns)
            tableList.append(table)
        isOk = True
        columns = []
        tableName = name
    elif dataType == 'composite':  # todo: need to handle composite key
        continue
    elif notNull != 'yes':
        continue
    else:
        columns.append(Column(name=name, type=dataType, defaultValue=default))

table = Table(name=tableName, columns=columns)
tableList.append(table)

for t in tableList:
예제 #12
0
파일: seed.py 프로젝트: nurarenke/Seater
def create_example_data():

    # add fake users to database
    store_users()

    # grab the first user
    event_owner = User.query.first()

    # add a fake event to the database
    gala_dinner = Event(event_name='Gala Dinner',
                        event_description='Fundraiser',
                        location='Four Seasons')

    # match the user id to the event
    gala_dinner.user_id = event_owner.user_id

    # add attendees to the event
    store_attendees(gala_dinner)

    # commit our changes and add the event
    db.session.add(gala_dinner)
    db.session.commit()

    t_one = Table(table_name='Test Table',
                  max_seats=10,
                  event_id=gala_dinner.event_id)
    t_two = Table(table_name='Test Table Two',
                  max_seats=10,
                  event_id=gala_dinner.event_id)
    t_three = Table(table_name='Test Table Three',
                    max_seats=10,
                    event_id=gala_dinner.event_id)
    t_four = Table(table_name='Test Table Four',
                   max_seats=10,
                   event_id=gala_dinner.event_id)
    t_five = Table(table_name='Test Table Five',
                   max_seats=10,
                   event_id=gala_dinner.event_id)

    db.session.add_all([t_one, t_two, t_three, t_four, t_five])
    db.session.commit()

    r_one = SeatingRelationship(primary_attendee=1,
                                secondary_attendee=2,
                                relationship_code='must')
    db.session.add(r_one)
    db.session.commit()

    r_two = SeatingRelationship(primary_attendee=3,
                                secondary_attendee=4,
                                relationship_code='must')
    db.session.add(r_two)
    db.session.commit()

    r_three = SeatingRelationship(primary_attendee=5,
                                  secondary_attendee=6,
                                  relationship_code='must')
    db.session.add(r_three)
    db.session.commit()

    r_four = SeatingRelationship(primary_attendee=8,
                                 secondary_attendee=9,
                                 relationship_code='must')
    db.session.add(r_four)
    db.session.commit()

    r_five = SeatingRelationship(primary_attendee=6,
                                 secondary_attendee=7,
                                 relationship_code='must_not')
    db.session.add(r_five)
    db.session.commit()

    r_six = SeatingRelationship(primary_attendee=7,
                                secondary_attendee=4,
                                relationship_code='want')
    db.session.add(r_six)
    db.session.commit()
예제 #13
0
app = Flask(__name__)
app.secret_key = os.urandom(12)
app.config["SQLALCHEMY_DATABASE_URI"] = 'sqlite:///allData.db'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

db = SQLAlchemy(app)
#
# if 'userData.db' is None:
#     print('Creating Database')
#     db.create_all()

from model import Table

if Table.query.filter_by(username='******', password='******').first() is None:
    admin = Table(username='******',
                  password='******',
                  email='*****@*****.**',
                  phoneNo='123456789')
    db.session.add(admin)
    db.session.commit()


def login_required(f):
    @wraps(f)
    def wrap(*args, **kwargs):
        if "logged_in" in session:
            return f(*args, **kwargs)
        else:
            flash("You need to LogIn First")
            return redirect("/")

    return wrap