cuducos / alchemydumps Goto Github PK
View Code? Open in Web Editor NEWSQLAlchemy backup/dump tool for Flask
License: MIT License
SQLAlchemy backup/dump tool for Flask
License: MIT License
Hello!
I tried making use of your package some days ago and I noticed this error popping on my console.
It says the import style used for Flask_Script
is the deprecated one: flask.ext.script
, I see in your codebase you've changed it but I doubt you've published those changes on pypi
. Can you rectify please, thanks!
Hello,
Python 3 support could be added with one line to setup.py
use_2to3=True
In case my flask script manager is created using a factory pattern, like this:
manager = script.Manager(app_factory)
How am I supposed to initialize Dumps?
There's some problem in backup.py
Can you make check so that slashes doesn't get added to win path.
Otherwise Backup works well with flask script and py 3.4, haven't tested restore jet.
Thanks for this extension, makes life easier.
something like:
import sys
@staticmethod
def __slashes(string):
"""Adds, if needed, a slash to the beginning and ending of a string"""
is_winows = sys.platform.startswith('win')
if not is_winows:
if string and len(string) > 1:
if string[0:1] != '/':
string = '/{}'.format(string)
if string[-1] != '/':
string = '{}/'.format(string)
return string
Hi, Can we please assign a license, MIT license or otherwise, to this repository?
Thank you!
Example:
In [1]: from sqlalchemy.ext.serializer import loads, dumps
In [2]: from ext.user.table.user import UserTable as User
In [3]: users = User.query.all()
In [4]: s = dumps(users[0])
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-4-9cf913d7f7a1> in <module>()
----> 1 s = dumps(users[0])
IndexError: list index out of range
In [5]: db = app.extensions['alchemydumps'].db
In [6]: db.session.add(User(email='a@a'))
In [7]: db.session.commit()
In [8]: users = User.query.all()
In [9]: s = dumps(users[0])
In [10]:
Traceback (most recent call last):
File "/home/viktor/Software/pycharm-community-4.5.2/helpers/pydev/pydevd.py", line 2357, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "/home/viktor/Software/pycharm-community-4.5.2/helpers/pydev/pydevd.py", line 1777, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "/github/vlikin/car_budget/flask/manage.py", line 11, in <module>
script_manager.run()
File "/github/vlikin/car_budget/flask/.env/local/lib/python2.7/site-packages/flask_script/__init__.py", line 412, in run
result = self.handle(sys.argv[0], sys.argv[1:])
File "/github/vlikin/car_budget/flask/.env/local/lib/python2.7/site-packages/flask_script/__init__.py", line 383, in handle
res = handle(*args, **config)
File "/github/vlikin/car_budget/flask/.env/local/lib/python2.7/site-packages/flask_script/commands.py", line 216, in __call__
return self.run(*args, **kwargs)
File "/github/vlikin/car_budget/flask/.env/local/lib/python2.7/site-packages/flask_alchemydumps/__init__.py", line 48, in create
data = alchemy.get_data()
File "/github/vlikin/car_budget/flask/.env/local/lib/python2.7/site-packages/flask_alchemydumps/helpers/database.py", line 38, in get_data
data[model.__name__] = dumps(query.all())
File "/github/vlikin/car_budget/flask/.env/local/lib/python2.7/site-packages/sqlalchemy/ext/serializer.py", line 152, in dumps
pickler.dump(obj)
File "/github/vlikin/car_budget/flask/.env/lib/python2.7/copy_reg.py", line 70, in _reduce_ex
raise TypeError, "can't pickle %s objects" % base.__name__
TypeError: <flask_script.commands.Command object at 0x7fcbaad5c750>: can't pickle function objects
Hello Everyone,
love this project but it is not functioning on my side due to this line in the
__init__.py
file at this line:
from flask.ext.script import Manager
Simply changed to
from flask_script import Manager
after installed the packages locally. This way it works.
Something changes in Travis and tox
is not able to find the right Python versions. A fiz is needed here: either by fixing .travis.yml
or migrating to another CI.
A nice feature would be to save the backup files at a file storage as S3.
Hello,
Not sure what's going on here. I have the following in my __init__.py
:
from flask_sqlalchemy import SQLAlchemy
from flask_alchemydumps import AlchemyDumps
from flask_migrate import Migrate
db = SQLAlchemy()
alchemydumps = AlchemyDumps()
migrate = Migrate()
def create_app(config_class=Config):
app = Flask(__name__)
app.config.from_object(config_class)
db.init_app(app)
migrate.init_app(app, db)
alchemydumps.init_app(app, db)
The flask_migrate
module has successfully registered a new flask db
command, but I don't have a flask alchemydumps
command, which is what I would expect from the cli.py
file contents. I don't have other commands that would match either:
> pipenv run flask --help
Usage: flask [OPTIONS] COMMAND [ARGS]...
A general utility script for Flask applications.
Provides commands from Flask, extensions, and the application. Loads the
application defined in the FLASK_APP environment variable, or from a
wsgi.py file. Setting the FLASK_ENV environment variable to 'development'
will enable debug mode.
$ export FLASK_APP=hello.py
$ export FLASK_ENV=development
$ flask run
Options:
--version Show the flask version
--help Show this message and exit.
Commands:
db Perform database migrations.
routes Show the routes for the app.
run Run a development server.
shell Run a shell in the app context.
Any idea what would cause the CLI command not to register?
Thanks,
Clément
Hi @cuducos, I would be willing to take over management of this package.
I don't have a forked version of changes I've made to this package, but have modified a majority of the code and placed inside another app of mine (running python 3.6 on an AWS Lambda). If I was given maintership of this package this is the direction I would like to take it in based on my current modifications:
Thanks for the code! This package was really, really, helpful in building my latest application and I'd love the chance to take it in new directions for others to enjoy.
-- les
Hi,
I have a multiple models with abstract model; it not working
Thanks.
Kind regards and many thanks in advance.
Their official solution coverallsapp/github-action
was failing with No build matching CI build number
so I left it out of 889346f
lets say I have configured the alchemydumps in this manner:
alchemydumps = AlchemyDumps(app, data_base)
is it possible to call the backup directly within the flask app e.g:
alchemydumps.backup()
Can I backup the file in different extensions..?, such as .zip or plaint text..?
Hi,
while using vsftpd as a ftp-server pushing the data to, an issue in the backup/helpers.py occurred. The response code is compared very strict against '250 OK'. With vsftpd a successfull directory-change-response get '250 Directory changed' so the socket-connection get closed in the middle of the transaction and raise an exception.
Changing.
if change_path[0:3] != '250':
ftp.quit()
to
if change_path[0:6] != '250 OK':
ftp.quit()
Would fix the issue. Can you please look at the issue or suggest a ftp-server, with a "250 OK" response?.
Thank you very much.
Marcus
If, for example, your database contains an association table for a many-to-many mapping as described here: http://docs.sqlalchemy.org/en/latest/orm/basic_relationships.html#many-to-many, the many-to-many association table doesn't get dumped by alchemy dumps. This seems to be because the base declarative class's subclasses are the only things enumerated when creating dumps, which will result in missing other data. Some other examples of usages that alchemydumps doesn't support can be found here: http://docs.sqlalchemy.org/en/latest/orm/nonstandard_mappings.html
Would it work to enumerate db.Model.metadata.tables and dump the contents that way instead?
This might make this package more useful in environments such as Heroku.
This is an example that could be useful.
This is in my TODO list, but anyone is free to jump in and make PR.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.