Skip to content
Snippets Groups Projects
Select Git revision
  • d57ba942f4dd9837df2bf5425acc96b34345635b
  • 3.9 default
  • develop
  • 6.0
  • 5.0
  • 4.0
  • scrutinizer-patch-4
  • scrutinizer-patch-3
  • scrutinizer-patch-2
  • scrutinizer-patch-1
  • 3.7
  • 3.8
  • 3.6
  • 3.9_backported
  • 3.8_backported
  • 3.7_backported
  • 3.5
  • 3.6_backported
  • 3.5_backported
  • 3.4
  • 3.3_backported
  • 6.0.4
  • 6.0.3
  • 5.0.7
  • 6.0.2
  • 6.0.1
  • 5.0.6
  • 6.0.0
  • 5.0.5
  • 6.0.0-rc
  • 5.0.4
  • 6.0.0-beta
  • 5.0.3
  • 4.0.6
  • 5.0.2
  • 5.0.1
  • 4.0.5
  • 5.0.0
  • 4.0.4
  • 5.0.0-rc2
  • 5.0.0-rc1
41 results

BuildDocTest.php

Blame
  • example2.py 1.08 KiB
    from sys import stderr
    from math import inf
    
    from sqlalchemy.exc import SQLAlchemyError
    from values import ValueDatabase, Value
    
    from kivy.app import App
    from kivy.properties import NumericProperty
    
    
    class Example2App(App):
        smallest_positive = NumericProperty(inf)
    
        @staticmethod
        def _find_smallest_positive(values):
            result = inf
            for value in values:
                if 0 < value < result:
                    result = value
            return result
    
        def on_start(self):
            url = ValueDatabase.construct_mysql_url('localhost', 3306, 'values', 'root', 'cse1208')
            value_database = ValueDatabase(url)
            session = value_database.create_session()
            values = [record.value for record in session.query(Value).all()]
            self.smallest_positive = Example2App._find_smallest_positive(values)
    
    
    def main():
        try:
            app = Example2App()
            app.run()
        except SQLAlchemyError as exception:
            print('Database connection failed!', file=stderr)
            print(f'Cause: {exception}', file=stderr)
            exit(1)
    
    
    if __name__ == '__main__':
        main()