Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix database name being ignored #866

Merged
merged 2 commits into from
Jul 21, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 8 additions & 11 deletions chatterbot/storage/sql_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class SQLStorageAdapter(StorageAdapter):
can be especified to choose database driver (database parameter will be igored).
:type database_uri: str

:keyword read_only: False by default, makes all operations read only, has priority over all DB operations
:keyword read_only: False by default, makes all operations read only, has priority over all DB operations
so, create, update, delete will NOT be executed
:type read_only: bool

Expand All @@ -104,20 +104,17 @@ def __init__(self, **kwargs):
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker

self.database_name = self.kwargs.get("database")

if self.database_name:

# Create a sqlite file if a database name is provided
self.database_uri = self.kwargs.get(
"database_uri", "sqlite:///" + self.database_name + ".db"
)

# The default uses sqlite in-memory database
# The default uses a sqlite in-memory database
self.database_uri = self.kwargs.get(
"database_uri", "sqlite://"
)

database_name = self.kwargs.get("database")

# Create a sqlite file if a database name is provided
if database_name:
self.database_uri = "sqlite:///" + database_name + ".db"

self.engine = create_engine(self.database_uri)

self.read_only = self.kwargs.get(
Expand Down