How to use _created method in molecule

Best Python code snippet using molecule_python

f49f6dc9b600_add__created_and__modified_fields_to_.py

Source:f49f6dc9b600_add__created_and__modified_fields_to_.py Github

copy

Full Screen

1"""Add _created and _modified fields to all tables2Revision ID: f49f6dc9b6003Revises: ab732474a8294Create Date: 2018-04-26 23:21:25.3754255"""6from alembic import op7import sqlalchemy as sa8# revision identifiers, used by Alembic.9revision = 'f49f6dc9b600'10down_revision = 'ab732474a829'11branch_labels = None12depends_on = None13def upgrade():14 op.add_column('LabelSelections', sa.Column('_created', sa.DateTime(), server_default=sa.text('now()'), nullable=False))15 op.add_column('LabelSelections', sa.Column('_modified', sa.DateTime(), server_default=sa.text('now()'), nullable=False))16 op.add_column('Labels', sa.Column('_created', sa.DateTime(), server_default=sa.text('now()'), nullable=False))17 op.add_column('Labels', sa.Column('_modified', sa.DateTime(), server_default=sa.text('now()'), nullable=False))18 op.add_column('Roles', sa.Column('_created', sa.DateTime(), server_default=sa.text('now()'), nullable=False))19 op.add_column('Roles', sa.Column('_modified', sa.DateTime(), server_default=sa.text('now()'), nullable=False))20 op.add_column('ScanCategories', sa.Column('_created', sa.DateTime(), server_default=sa.text('now()'), nullable=False))21 op.add_column('ScanCategories', sa.Column('_modified', sa.DateTime(), server_default=sa.text('now()'), nullable=False))22 op.add_column('Scans', sa.Column('_created', sa.DateTime(), server_default=sa.text('now()'), nullable=False))23 op.add_column('Scans', sa.Column('_modified', sa.DateTime(), server_default=sa.text('now()'), nullable=False))24 op.add_column('Slices', sa.Column('_created', sa.DateTime(), server_default=sa.text('now()'), nullable=False))25 op.add_column('Slices', sa.Column('_modified', sa.DateTime(), server_default=sa.text('now()'), nullable=False))26 op.add_column('Users', sa.Column('_created', sa.DateTime(), server_default=sa.text('now()'), nullable=False))27 op.add_column('Users', sa.Column('_modified', sa.DateTime(), server_default=sa.text('now()'), nullable=False))28def downgrade():29 op.drop_column('Users', '_modified')30 op.drop_column('Users', '_created')31 op.drop_column('Slices', '_modified')32 op.drop_column('Slices', '_created')33 op.drop_column('Scans', '_modified')34 op.drop_column('Scans', '_created')35 op.drop_column('ScanCategories', '_modified')36 op.drop_column('ScanCategories', '_created')37 op.drop_column('Roles', '_modified')38 op.drop_column('Roles', '_created')39 op.drop_column('Labels', '_modified')40 op.drop_column('Labels', '_created')41 op.drop_column('LabelSelections', '_modified')...

Full Screen

Full Screen

1_7_decorator_demo01.py

Source:1_7_decorator_demo01.py Github

copy

Full Screen

1#!/usr/bin/python2# -*- encoding: utf-8 -*-3"""4装饰类5"""6import functools7import time8def sortable_by_creation_time(cls):9 """Given a class, augment the class to have its instances be sortable10 by the timestamp at which they were instantiated.11 """12 # Augment the class original `__init__` method to also store a 13 # `_created` attribute on the instance, which corresponds to when it14 # was instantiated.15 original_init = cls.__init__16 @functools.wraps(original_init)17 def new_init(self, *args, **kwargs):18 original_init(self, *args, **kwargs)19 self._created = time.time()20 cls.__init__ = new_init21 # Add `__lt__` and `__gt__` methods that return True or False based on22 # the created values in question.23 cls.__lt__ = lambda self, other: self._created < other._created24 cls.__gt__ = lambda self, other: self._created > other._created25 # Done; return the class object26 return cls27@sortable_by_creation_time28class Sortable(object):29 """docstring for Sortable"""30 def __init__(self, identifier):31 self.identifier = identifier32 def __repr__(self):33 return self.identifier34first = Sortable('1')35second = Sortable('2')36third = Sortable('3')37print(first._created)38print(second._created)39print(third._created)40sortables = [third, second, first]41print(sorted(sortables))...

Full Screen

Full Screen

create-providers.py

Source:create-providers.py Github

copy

Full Screen

1from django.core.management.base import BaseCommand2from mce_django_app import constants3from mce_django_app.models.common import Provider4class Command(BaseCommand):5 help = 'Create or Update all providers'6 def _run_command(self):7 _created = 08 _updated = 09 for p in constants.Provider:10 provider, created = Provider.objects.update_or_create(name=p.value)11 if created:12 _created += 113 else:14 _updated += 115 return _created, _updated16 def handle(self, *args, **options):17 _created, _updated = self._run_command()18 msg = f"create provider - created[{_created}] - updated[{_updated}]"...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run molecule automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful