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

Refactor operations #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ pytest==2.5.2
schema==0.3.1
psutil==2.1.1
click==3.1
SQLAlchemy-Utils==0.26.11
SQLAlchemy-Utils==0.26.13
11 changes: 3 additions & 8 deletions stellar/operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,9 @@ def copy_database(raw_conn, from_database, to_database):
terminate_database_connections(raw_conn, from_database)

if raw_conn.engine.dialect.name == 'postgresql':
raw_conn.execute(
'''
CREATE DATABASE "%s" WITH TEMPLATE "%s";
''' %
(
to_database,
from_database
)
sqlalchemy_utils.functions.create_database(
'%s%s' % (raw_conn.engine.url, to_database),
template=from_database
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we consider checking if the function exists, use it if it does and fallback to the current mechanism if it doesn't?

That would avoid having to rely on the latest sqlalchemy-utils

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pypingou , it was 3 years ago, but from your requirements.txt it looks like you do rely on sqlalchemy-utils and operations.py imports it so it looks like the idea contained in this pull request could be merged.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point was not about relying on something that is already listed in the dependency list but about being more flexible on versions sqlalchemy-utils required.
After three years I think this point is no longer valid (and I even wonder how/why you digged up this comment ^^)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's open! I had a quick look and didn't really understood what is it about, you do rely on sqlalchemy-utils.

What's interesting is, why was I looking at the bug tracker. The reason is, I was wondering if I should add a command-line option to use another configuration file (different filename). The two or three times I thought this would be useful I ended up doing some other solution instead.

This whole stellar package is interesting. The functionality is so small and provided by PostgreSQL already it makes me wonder if I really need this package. On the other hand there is something really tempting about just typing "stellar restore" and having things done. On another, stellar is the thing I learned "CREATE TABLE FROM TEMPLATE" about.

Anyways.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's open!

Fair point, I had not realized this, but I doubt that it is my 3 years old comment that is preventing this PR from being merged.

It looks like the last commit on this project is from 2 years ago, so this project seems a little dead now, pity :(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just that the project has reached a point where it works good enough so there hasn't really been any need for changes. I'm still using it every week so it's far from being abandoned.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, good to know! :)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Frozenball glad to have you here, I'm also regular stellar user

)
elif raw_conn.engine.dialect.name == 'mysql':
# Horribly slow implementation.
Expand Down