Hi,

I'm trying unsuccessfully to load data in a django multi-database
environment.
I try to store some data as tree. I used django-mptt and django-
treebeard and obtain same results.

In my settings.py, I have 2 databases:
- 'default' database with sqlite3;
- 'A_Africa_Branch_01' as second database with postgresql.

To be complete:
- Before switching to postgresql, I ran 2 sqlite3 databases and got
same results;
- I wrote a router and it seems to work fine;
- Using only one database ('default'), I succeed to load all my data.

I import data to the table with a file: fill_up_branch_mptt .py.


Part of the file is:

get = lambda node_id:
BranchLocation.objects.using('A_Africa_Branch_01').get(pk=node_id)

root = BranchLocation.add_root(branch_location='A_Africa_Branch_01',
identity=1111)
node = get(root.id).add_child(branch_location='Region_01',
identity=1121)

get(node.id).add_child(branch_location='Area_01', identity=1777)
get(node.id).add_child(branch_location='Area_02', identity=1778)
# File continue here


When I use 2 databases: “DatabaseError: no such table:
branch_branchlocation”.
But, the table exists and the two first lines of data are recorded in
it.

Recorded information are:
row_1(root): branch_location='A_Africa_Branch_01', identity=1111
row_2(node): branch_location='Region_01', identity=1121

Not recorded information are: all node children.


and Traceback is:

jk@cc tree$ ./manage.py shell
Python 2.7 (r27:82500, Sep 16 2010, 18:03:06)
[GCC 4.5.1 20100907 (Red Hat 4.5.1-3)] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
(InteractiveConsole)
>>> import fill_up_branch_mptt
Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/home/jk/eclipse/tree/tree/fill_up_branch_mptt.py", line 63,
in <module>
    node = get(root.id).add_child(branch_location='Region_01',
identity=1121)
  File "/usr/lib/python2.7/site-packages/django_treebeard-1.61-
py2.7.egg/treebeard/mp_tree.py", line 538, in add_child
    cursor.execute(sql, [self.path])
  File "/usr/lib/python2.7/site-packages/django/db/backends/util.py",
line 15, in execute
    return self.cursor.execute(sql, params)
  File "/usr/lib/python2.7/site-packages/django/db/backends/sqlite3/
base.py", line 200, in execute
    return Database.Cursor.execute(self, query, params)
DatabaseError: no such table: branch_branchlocation
>>>

I used django-mptt for the save() method with
save(using='A_Africa_Branch_01') and got the same Traceback.
Reading last line of traceback there is  “django/db/backends/sqlite3/
base.py”.

Someone know this problem or where I can find documentation for using
mptt or treebeard inside a multi-database environment ?

Thanks in advance for your answers.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to