Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
database_design
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Brady James Garvin
database_design
Commits
f68d4d8e
Commit
f68d4d8e
authored
Mar 29, 2019
by
Brady James Garvin
Browse files
Options
Downloads
Patches
Plain Diff
Updated codebase for 2019.
parent
3acba0b1
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+0
-1
0 additions, 1 deletion
.gitignore
diet.py
+3
-4
3 additions, 4 deletions
diet.py
diet_installer.py
+2
-4
2 additions, 4 deletions
diet_installer.py
with
5 additions
and
9 deletions
.gitignore
+
0
−
1
View file @
f68d4d8e
...
...
@@ -2,5 +2,4 @@
*.pyo
.idea
.buildozer
bin
This diff is collapsed.
Click to expand it.
diet.py
+
3
−
4
View file @
f68d4d8e
...
...
@@ -3,14 +3,13 @@ from sqlalchemy.ext.declarative import declarative_base
from
sqlalchemy.orm
import
sessionmaker
,
relationship
Persisted
=
declarative_base
()
Persisted
=
declarative_base
()
# pylint: disable=invalid-name
class
DietDatabase
(
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
():
...
...
@@ -18,7 +17,7 @@ class DietDatabase(object):
def
__init__
(
self
,
url
):
self
.
engine
=
create_engine
(
url
)
self
.
Session
=
sessionmaker
()
self
.
Session
=
sessionmaker
()
# pylint: disable=invalid-name
self
.
Session
.
configure
(
bind
=
self
.
engine
)
def
ensure_tables_exist
(
self
):
...
...
...
...
This diff is collapsed.
Click to expand it.
diet_installer.py
+
2
−
4
View file @
f68d4d8e
# -*- coding: utf-8; -*-
from
sys
import
stderr
from
sqlalchemy.exc
import
SQLAlchemyError
...
...
@@ -10,7 +8,7 @@ from diet import DietDatabase
def
add_starter_data
(
session
):
pass
# TODO: stub
pass
def
main
():
...
...
@@ -25,7 +23,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
)
...
...
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment