Skip to content
Snippets Groups Projects
Select Git revision
  • fa526a95090064c75e579ea9821aa4ccaea258a5
  • 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

CompanyBankAccountTest.php

Blame
  • values_installer.py 873 B
    from sys import stderr
    
    from sqlalchemy.exc import SQLAlchemyError
    
    from values import ValueDatabase, Value
    
    
    def add_starter_data(session):
        one = Value(value=1.0)
        two = Value(value=2.0)
        three = Value(value=3.0)
        session.add(one)
        session.add(two)
        session.add(three)
    
    
    def main():
        try:
            url = ValueDatabase.construct_mysql_url('localhost', 3306, 'values', 'root', 'cse1208')
            value_database = ValueDatabase(url)
            value_database.ensure_tables_exist()
            print('Tables created.')
            session = value_database.create_session()
            add_starter_data(session)
            session.commit()
            print('Records created.')
        except SQLAlchemyError as exception:
            print('Database setup failed!', file=stderr)
            print(f'Cause: {exception}', file=stderr)
            exit(1)
    
    
    if __name__ == '__main__':
        main()