librelist archives

« back to archive

raise exceptions.DatabaseAlreadyControlledError(migrate)

raise exceptions.DatabaseAlreadyControlledError(migrate)

From:
peg kh
Date:
2014-12-29 @ 18:00
I got this error How can I fix it ? Thanx If you could help
Error
Traceback (most recent call last):
  File "db_create.py", line 15, in <module>
    api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO,
api.version(SQLALCHEMY_MIGRATE_REPO))
  File "<string>", line 2, in version_control
  File

"/home/peg/flask/venv/local/lib/python2.7/site-packages/migrate/versioning/util/__init__.py",
line 159, in with_engine
    return f(*a, **kw)
  File

"/home/peg/flask/venv/local/lib/python2.7/site-packages/migrate/versioning/api.py",
line 250, in version_control
    ControlledSchema.create(engine, repository, version)
  File

"/home/peg/flask/venv/local/lib/python2.7/site-packages/migrate/versioning/schema.py",
line 139, in create
    table = cls._create_table_version(engine, repository, version)
  File

"/home/peg/flask/venv/local/lib/python2.7/site-packages/migrate/versioning/schema.py",
line 187, in _create_table_version
    raise exceptions.DatabaseAlreadyControlledError
migrate.exceptions.DatabaseAlreadyControlledError

db_create.py

from migrate.versioning import api
from config import SQLALCHEMY_DATABASE_URI
from config import SQLALCHEMY_MIGRATE_REPO
from app import db

import os.path
db.create_all()
if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
    api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
    api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
else:
    api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO,
api.version(SQLALCHEMY_MIGRATE_REPO))

config.py
CSRF_ENABLE = True
SECRET_KEY = 'Thisismysecretkey '
import os
basedir = os.path.abspath(os.path.dirname(__file__))
SQLALCHEMY_DATABASE_URI = 'sqlite:///'+os.path.join(basedir, 'app.db')
SQLALCHEMY_MIGRATE_REPO = os.path.join(basedir, 'db_repository')

#pagination
MONKEYS_PER_PAGE = 6

Re: [flask] raise exceptions.DatabaseAlreadyControlledError(migrate)

From:
Jeremy Dagorn
Date:
2014-12-29 @ 18:37
What have you tried? What did you find after looking for your issue on
Google?


On Mon, Dec 29, 2014 at 10:00 AM, peg kh <peg1988.kh@gmail.com> wrote:

> I got this error How can I fix it ? Thanx If you could help
> Error
> Traceback (most recent call last):
>   File "db_create.py", line 15, in <module>
>     api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO,
> api.version(SQLALCHEMY_MIGRATE_REPO))
>   File "<string>", line 2, in version_control
>   File
> 
"/home/peg/flask/venv/local/lib/python2.7/site-packages/migrate/versioning/util/__init__.py",
> line 159, in with_engine
>     return f(*a, **kw)
>   File
> 
"/home/peg/flask/venv/local/lib/python2.7/site-packages/migrate/versioning/api.py",
> line 250, in version_control
>     ControlledSchema.create(engine, repository, version)
>   File
> 
"/home/peg/flask/venv/local/lib/python2.7/site-packages/migrate/versioning/schema.py",
> line 139, in create
>     table = cls._create_table_version(engine, repository, version)
>   File "/home/peg/flask/venv/l
> ocal/lib/python2.7/site-packages/migrate/versioning/schema.py", line 187,
> in _create_table_version
>     raise exceptions.DatabaseAlreadyControlledError
> migrate.exceptions.DatabaseAlreadyControlledError
>
> db_create.py
>
> from migrate.versioning import api
> from config import SQLALCHEMY_DATABASE_URI
> from config import SQLALCHEMY_MIGRATE_REPO
> from app import db
>
> import os.path
> db.create_all()
> if not os.path.exists(SQLALCHEMY_MIGRATE_REPO):
>     api.create(SQLALCHEMY_MIGRATE_REPO, 'database repository')
>     api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO)
> else:
>     api.version_control(SQLALCHEMY_DATABASE_URI, SQLALCHEMY_MIGRATE_REPO,
> api.version(SQLALCHEMY_MIGRATE_REPO))
>
> config.py
> CSRF_ENABLE = True
> SECRET_KEY = 'Thisismysecretkey '
> import os
> basedir = os.path.abspath(os.path.dirname(__file__))
> SQLALCHEMY_DATABASE_URI = 'sqlite:///'+os.path.join(b asedir, 'app.db')
> SQLALCHEMY_MIGRATE_REPO = os.path.join(basedir, 'db_repository')
>
> #pagination
> MONKEYS_PER_PAGE = 6
>



-- 
Jérémy Dagorn
www.jeremydagorn.com

Android apps I developed:
https://play.google.com/store/apps/developer?id=JumyApps