Relation between different database?

classic Classic list List threaded Threaded
9 messages Options
ANi
Reply | Threaded
Open this post in threaded view
|

Relation between different database?

ANi
Hi, 

I have my asset table in local db which need to reference to the employee view from another database. 
But I realized that Django might not allow relations across databases, right?

so does it means that I can only store the employee key as string in the asset table?
or other way to achieve?

many thanks,
ANi

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4cd4ea88-d6c1-42c5-92d2-f9a5b7f818d8%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Relation between different database?

N'BE SORO
Hello. 

Give me one example 

Le mar. 10 sept. 2019 à 03:54, ANi <[hidden email]> a écrit :
Hi, 

I have my asset table in local db which need to reference to the employee view from another database. 
But I realized that Django might not allow relations across databases, right?

so does it means that I can only store the employee key as string in the asset table?
or other way to achieve?

many thanks,
ANi

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4cd4ea88-d6c1-42c5-92d2-f9a5b7f818d8%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp9p2jLEq-T2VmbY8mBq_H8-jjX7a2cG%2Bb5HPk-_AH5dKg%40mail.gmail.com.
ANi
Reply | Threaded
Open this post in threaded view
|

Re: Relation between different database?

ANi
In reply to this post by ANi
my real situation as an example.

local database
AssetModel(id, employee, name, barcode, location, value)

remote database
EmployeeView(id, name, department)

I am thinking to set employee in AssetModel as an ForeignKey which references to EmployeeView.
but it seems to be not allowed


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4617ae94-1cf1-42be-8441-2ba84e9d04ef%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Relation between different database?

N'BE SORO
Ok you can add an additional column my_id and you give him the unique property = True

Le mar. 10 sept. 2019 à 06:00, ANi <[hidden email]> a écrit :
my real situation as an example.

local database
AssetModel(id, employee, name, barcode, location, value)

remote database
EmployeeView(id, name, department)

I am thinking to set employee in AssetModel as an ForeignKey which references to EmployeeView.
but it seems to be not allowed


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4617ae94-1cf1-42be-8441-2ba84e9d04ef%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp9trTFp8ksbv2Y_TYeTHZp0gvi%3DaakN5GhgpEhBEXJPxA%40mail.gmail.com.
ANi
Reply | Threaded
Open this post in threaded view
|

Re: Relation between different database?

ANi
In reply to this post by ANi
the key point is about the relation in different databases,
if it is possible to have relations, then I don't need to write additional code to access data from the remote one.


ANi於 2019年9月10日星期二 UTC+8上午11時54分28秒寫道:
Hi, 

I have my asset table in local db which need to reference to the employee view from another database. 
But I realized that Django might not allow relations across databases, right?

so does it means that I can only store the employee key as string in the asset table?
or other way to achieve?

many thanks,
ANi

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/fd08e15f-c868-478c-a82d-542867364121%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Relation between different database?

Jason Johns
https://docs.djangoproject.com/en/2.2/topics/db/multi-db/

If you have to do this, Django does support multiple databases. But you’re going to need to handle the data consistency and integrity you’r.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/a4b77e83-63c4-430f-b311-a7c7fad6d5db%40googlegroups.com.
ANi
Reply | Threaded
Open this post in threaded view
|

Re: django-import-export problem with relation of two databases

ANi
In reply to this post by ANi
Thanks, Jason.
Then another question, actually why I am asking this is because I am using django-export-import, 
I think it is better to have another title.

This is my router, I've set the foreignkey between A Model from default database and EmpAXView from emp database.
django-export-import tells me this:
no such table: main.View_EmpAX
or the relation is not allowed.

so I am thinking it is the problem of allow_relation method. but I don't get the concept about how to write it..........

擷取.PNG



ANi於 2019年9月10日星期二 UTC+8上午11時54分28秒寫道:
Hi, 

I have my asset table in local db which need to reference to the employee view from another database. 
But I realized that Django might not allow relations across databases, right?

so does it means that I can only store the employee key as string in the asset table?
or other way to achieve?

many thanks,
ANi

ANi於 2019年9月10日星期二 UTC+8上午11時54分28秒寫道:
Hi, 

I have my asset table in local db which need to reference to the employee view from another database. 
But I realized that Django might not allow relations across databases, right?

so does it means that I can only store the employee key as string in the asset table?
or other way to achieve?

many thanks,
ANi

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/19635e18-c095-4cf4-93fa-336a07cb9908%40googlegroups.com.
ANi
Reply | Threaded
Open this post in threaded view
|

Re: Relation between different database?

ANi
In reply to this post by ANi
Thanks, Jason.

I was trying to connect a table to a view from another database.
But it is not allowed to have a foreign key on a view unless I use a materialized view! 
Problem is solved. 




ANi於 2019年9月10日星期二 UTC+8上午11時54分28秒寫道:
Hi, 

I have my asset table in local db which need to reference to the employee view from another database. 
But I realized that Django might not allow relations across databases, right?

so does it means that I can only store the employee key as string in the asset table?
or other way to achieve?

many thanks,
ANi

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/94f3298b-a879-49ae-ac5f-52f1f7d6109e%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: django-import-export problem with relation of two databases

Most. Runa
In reply to this post by ANi
Now i am full sexul mood guys coming my puss kiss 

On Wed, 11 Sep 2019, 6:51 a.m. ANi, <[hidden email]> wrote:
Thanks, Jason.
Then another question, actually why I am asking this is because I am using django-export-import, 
I think it is better to have another title.

This is my router, I've set the foreignkey between A Model from default database and EmpAXView from emp database.
django-export-import tells me this:
no such table: main.View_EmpAX
or the relation is not allowed.

so I am thinking it is the problem of allow_relation method. but I don't get the concept about how to write it..........

擷取.PNG



ANi於 2019年9月10日星期二 UTC+8上午11時54分28秒寫道:
Hi, 

I have my asset table in local db which need to reference to the employee view from another database. 
But I realized that Django might not allow relations across databases, right?

so does it means that I can only store the employee key as string in the asset table?
or other way to achieve?

many thanks,
ANi

ANi於 2019年9月10日星期二 UTC+8上午11時54分28秒寫道:
Hi, 

I have my asset table in local db which need to reference to the employee view from another database. 
But I realized that Django might not allow relations across databases, right?

so does it means that I can only store the employee key as string in the asset table?
or other way to achieve?

many thanks,
ANi

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/19635e18-c095-4cf4-93fa-336a07cb9908%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK1otB%2BFfyLpbtGidBZgP7qG%2BAdpETzHEfONuJphKZp3ffVxeQ%40mail.gmail.com.