Skip to content
Snippets Groups Projects
Commit fbaa9153 authored by Brady James Garvin's avatar Brady James Garvin
Browse files

Updated code for Python 3.

parent 90b6329a
Branches master
No related tags found
No related merge requests found
......@@ -8,7 +8,7 @@ from sqlalchemy.orm import sessionmaker, relationship
# class that we can use for objects that we want SQLAlchemy to persist in a
# database. We then store that class in variable named Persisted; effectively,
# we make a new class called Persisted.
Persisted = declarative_base()
Persisted = declarative_base() # pylint: disable=invalid-name
class Menu(Persisted):
......@@ -42,8 +42,7 @@ class OrderItem(Persisted):
class DinerDatabase(object):
@staticmethod
def construct_mysql_url(authority, port, database, username, password):
return 'mysql+mysqlconnector://{username}:{password}@{authority}:{port}/{database}' \
.format(authority=authority, port=port, database=database, username=username, password=password)
return f'mysql+mysqlconnector://{username}:{password}@{authority}:{port}/{database}'
@staticmethod
def construct_in_memory_url():
......@@ -51,7 +50,7 @@ class DinerDatabase(object):
def __init__(self, url):
self.engine = create_engine(url) # an engine is like an endpoint, something to connect to
self.Session = sessionmaker() # create a class for connections to that endpoint
self.Session = sessionmaker() # create a class for connections to that endpoint / pylint: disable=invalid-name
self.Session.configure(bind=self.engine) # associate the class with the endpoint
def ensure_tables_exist(self):
......
# -*- coding: utf-8; -*-
from sys import stderr
from sqlalchemy.exc import SQLAlchemyError
......@@ -34,7 +32,7 @@ def main():
print('Records created.')
except SQLAlchemyError as exception:
print('Database setup failed!', file=stderr)
print('Cause: {exception}'.format(exception=exception), file=stderr)
print(f'Cause: {exception}', file=stderr)
exit(1)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment