Code Monkey home page Code Monkey logo

django-db-multitenant's People

Contributors

brechin avatar georgski avatar m7salam avatar mik3y avatar mosajjal avatar stephane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-db-multitenant's Issues

Removing the necessity for TENANT_DATABASE_NAME in settings.py

Hi,

At the moment TENANT_DATABASE_NAME=example.com ./manage.py runserver doesn't work because django loads the settings after it tries to connect to mysql. This can be fixed by adding

python
from db_multitenant.utils import update_database_from_env

if not dbname:
utils.update_database_from_env(super(DatabaseWrapper, self).get_connection_params())
dbname = self.threadlocal.get_dbname()


to _cursor() between line 51 and 52 in db/backends/mysql/base.py.

[Feature Request] SQLite 3 support

Challenges

SQLite 3 does not support multi schemas/databases. Implementing a SQLite 3 database backend would require a novel approach.

Unfortunately, solely executing "USE" through the database cursor would not work for SQLite 3.

Proposed solution

At first thought, I planned to prepend the tenant's name to DATABASES["default"]["NAME"].

user, password and host

Hi,

I am a little confused at the setup for this. It looks like your multi-tenant is going to work for what I want. But, I don't see where to setup the USER, PASSWORD and HOST for the database. Could you advise?

Searching for an invalid database.

My settings.py is something like this:

DATABASES = {
'default': {
'ENGINE': 'db_multitenant.db.backends.mysql',
'NAME': 'test',
'USER': '****',
'PASSWORD': '**
**',
'HOST': '/Applications/MAMP/tmp/mysql/mysql.sock',
'PORT': '3306',
}
}

But its giving me the error
"OperationalError at /admin/
(1049, "Unknown database 'tenant-localhost'")"

I guess it should search for the "test" database, but its not.
Can you guys please guide me to right direction.Thanks in advance.

Unable to create super user using command shell

I am testing this library for a small project. I am using postgres db.
The problem I am facing is that I am unable to create super user from shell. I have specified database in the shell eg.
python manage.py createsuperuser --database mydb
and then i get the error

django.core.exceptions.ImproperlyConfigured: Tenant name not set at cursor create time.

Since there isn't any comprehensive documentation available for it, I wanted to ask if there is a way to work this out?

UPDATE: I even tried
TENANT_NAME=mydb ./manage.my migrate --database=mydb
where mydb is the name of tenant and also for the database

MemcachedStringEncodingError when using multitenant_key_func

I am getting

Keys must be str()'s, not unicode. Convert your unicode strings using mystring.encode(charset)!
when using cache.helper.multitenant_key_func

using key.encode('ascii', 'ignore') or django.utils.encoding.force_text on the returned key fixes it.

Question: Multiple Schema migrates

Thank you for this work ... I'm testing in an app at the moment with good success so far.
QUESTION: Is it possible to do multi schema updates at the same time for POSTGRESQL... e.g. TENANT_NAME=*?

Use PostgreSQL on this app

How many changes we have to do to allow this app to work with PostgreSQL? How complicated it could be?

I'm interested in using it with PostgreSQL because it is the only app that I found that implements the Isolated Approach.

Tenant after login

Hi @mik3y,

The requirement I'm trying to implement tells me that the tenant is known after a user is logged in, it means, the user table is shared or public and contains the tenant's name, and then we can have a different database per tenant.

Is this currently possible with your library?. Please give me some hints about implementing it if possible.

Thanks in advance.

Add new maintainer

I don't actively use this project any more, but looks like it has a modest user base, which is great.

@stephane would you like to be added as maintainer?

Per database management command execution

I have a working installation of django-db-multitenant, its perfect for my use case thanks.

However, I cannot get the management commands to work, such as:
TENANT_DATABASE_NAME=example.com ./manage.py migrate

How do I call such a command from a venv in Windows 10 Python installation?

Also, do you have a solution for looping the migration commands over multiple databases in MySQL (like database names app_bqt, app_cre, app_trb etc) ?

Conflict of licenses

The README states the project is under Apache 2 license but some files refer to 3-Clause BSD licence (such as utils.py).

Which is the license of the project?

error Tenant_name

TENANT_NAME=company ./manage.py migrate Erro "Is not recognized as an internal or external command
and I am using windows 10

SyncDB and South module stop working

Hi,

Good work, I like this module and it's working so far in my tests. But I found out some issues.

There's a problem using this module. If you use South to migrate your tables, this stop working with the error "Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x108ec2450>>"
My guess, it's that it's not supported for South.

Also, when using the 'ENGINE': 'db_multitenant.db.backends.mysql', commands like "python manage.py syncdb" or "python manage.py sql" return the error: "NameError: global name 'ImproperlyConfigured' is not defined"

How did you manage to solve your table migrations and creations?
Best Regards

dbname not set at cursor create time

I followed all the steps that you mentioned in your docs but I always get the same error "dbname not set at cursor create time" when I run the project. I even sent a static database name inside the mapper just to try it and it returned the same error. It looks like it cannot initiate with the default database that I already added inside the settings. Any suggestions?

mappers is not working in subdirectories

If i save my mapper in directory [app_config]\tenants\mapper - class Mapper

and in settings
MULTITENANT_MAPPER_CLASS = '[app_config].tenants.mapper.Mapper'

I will have an error

"Could not import mapper:..." - utils.py line 71

may be you need to replace try constuction?

        try:
            module_path, member_name = name.rsplit(".", 1)
            module = import_module(module_path)
            cls = getattr(module, member_name)

to

        try:
            from pydoc import locate
            cls = locate(name)

Isolated approach: on PostgreSQL

Hi,

In readme we red that "Isolated approach: Separate database per tenant." is just for MySQL ?,

We need this to work with PostgreSQL (Database per Tenant) not schema. is this possible with PostgreSQL ????

Thank you

New releases

I have a few minor changes to apply to the documentation and some tests to pass before publishing a new release. In the meantime, could you give me the right to push a new release on Pypi or do you want to publish them?

My pypi account is stephane.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.