Skip to content

Commit

Permalink
Corrected restructuring errors, database path
Browse files Browse the repository at this point in the history
Errors resulting from restructing have been fixed. In addition, sqlalchemy.url
has been removed from the config file. This now uses the db_file config setting,
and creates the sqlite db as required using the absolute path of the doll_db
folder.
  • Loading branch information
Matthew Badger authored and Matthew Badger committed Aug 30, 2015
1 parent 536d32c commit de6e3bd
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 19 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ publish/
*.publishproj

# NuGet Packages Directory
## TODO: If you have NuGet Package Restore enabled, uncomment the next line
#packages/

# Windows Azure Build Output
Expand Down Expand Up @@ -219,4 +218,7 @@ pip-log.txt
.idea/
__pycache__
*.pyc
*.pyo
*.pyo

# Database files
*.db
2 changes: 1 addition & 1 deletion doll/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__author__ = 'Matthew'
__author__ = 'Matthew Badger'
4 changes: 2 additions & 2 deletions doll/db_input_parser/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import os

from db_input_parser.add_database_types import create_type_contents
from db_input_parser.parse_dictionary import parse_dict_file
from doll.db_input_parser.add_database_types import create_type_contents
from doll.db_input_parser.parse_dictionary import parse_dict_file
from doll.db_input_parser.parse_inflections import parse_inflect_file


Expand Down
6 changes: 4 additions & 2 deletions doll/db_input_parser/add_database_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

__author__ = 'Matthew Badger'

from doll.doll_db import *

from doll.doll_db import Connection
from doll.doll_db.model import *

# Add the basic database types
def create_type_contents():
Expand Down Expand Up @@ -188,4 +188,6 @@ def create_type_contents():

Connection.session.add(Language(code='E', name='English', description='English translations from Words'))

Connection.create_all()

Connection.session.commit()
3 changes: 2 additions & 1 deletion doll/db_input_parser/parse_dictionary.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
__author__ = 'Matthew Badger'

from doll.doll_db import *
from doll.doll_db import Connection
from doll.doll_db.model import *

def parse_dict_file(dict_file, commit_changes=False):

Expand Down
3 changes: 2 additions & 1 deletion doll/db_input_parser/parse_inflections.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
__author__ = 'Matthew Badger'

from doll.doll_db import *
from doll.doll_db import Connection
from doll.doll_db.model import *

"""Parses the inflections input file.
Expand Down
18 changes: 12 additions & 6 deletions doll/doll_db/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
__author__ = 'Matthew Badger'


from os.path import dirname
from sqlalchemy import engine_from_config
from sqlalchemy.orm import sessionmaker
from sqlalchemy.ext.declarative import declarative_base

from doll.doll_db.config import config

Base = declarative_base()
from doll.doll_db.model import *


'''Connection class
Expand All @@ -17,11 +17,17 @@

# Connects to the database
class Connection:
__engine = engine_from_config(config, echo=False)
config = config

Base.metadata.create_all(__engine)
config['sqlalchemy.url'] = 'sqlite:///' + dirname(__file__) + '/doll.db'

__engine = engine_from_config(config, echo=False)

__Session = sessionmaker()
__Session.configure(bind=__engine)

session = __Session()
session = __Session()

@staticmethod
def create_all():
Base.metadata.create_all(Connection.__engine)
3 changes: 1 addition & 2 deletions doll/doll_db/config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
config = {
'db_file': 'doll_db/doll.db',
'sqlalchemy.url': 'sqlite:///doll_db/doll.db',
'db_file': 'doll.db',
'sqlalchemy.pool_recycle': '50',
'sqlalchemy.echo': 'false'
}
6 changes: 4 additions & 2 deletions doll/doll_db/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@

from sqlalchemy import Column, Integer, String, ForeignKey, Boolean, Unicode
from sqlalchemy.orm import relationship, backref
from sqlalchemy.ext.declarative import declared_attr
from sqlalchemy.ext.declarative import declarative_base, declared_attr


Base = declarative_base()

from doll.doll_db import Base

"""Basic Type Classes
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sqlalchemy==1.0.8

0 comments on commit de6e3bd

Please sign in to comment.