Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » copying sqlite database file between projects [RSS Feed]

#1 Jan. 25, 2011 15:36:10

Ben D.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

copying sqlite database file between projects


Hi all,

Afraid I've got another newbie question. I've been doing some
development on a project using sqlite3. All is working well, and I'd
like to use the same database file in another project, data intact.
I've copied the database file, and the models.py file to the
appropriate locations in the new project. When I run syncdb, the
only result is 'no fixtures found.'

When I pop into the shell, all the fields are there, but I can't get
to the data in any of them.

For instance, inside the shell for the new project I run:

Person.objects.all()

it returns



Do I need to do something besides just copying the database file to
keep my data, provided the models.py files are unchanged?

Many thanks,
Ben

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Jan. 25, 2011 15:46:04

Bill F.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

copying sqlite database file between projects


Do you have suitable file system permissions on the db file for use in
the new context?

Are the two usages (if they are on different machines, or in different accounts)
using the same version of sqlite? (I don't know enough about sqlite to know if
this is a problem, but it's worth checking.)

Does the settings.py configuration give an absolute path or relative
path including
"../some_dir/..." that doesn't work in the new context?

Bill

On Tue, Jan 25, 2011 at 10:36 AM, Ben Dembroski <i...@ionraystudios.com> wrote:
> Hi all,
>
> Afraid I've got another newbie question.   I've been doing some
> development on a project using sqlite3.  All is working well, and I'd
> like to use the same database file in another project, data intact.
> I've copied the database file, and the models.py file to the
> appropriate locations in the new project.   When I run syncdb, the
> only result is 'no fixtures found.'
>
> When I pop into the shell, all the fields are there, but I can't get
> to the data in any of them.
>
> For instance, inside the shell for the new project I run:
>
> Person.objects.all()
>
> it returns
>
>
>
> Do I need to do something besides just copying the database file to
> keep my data, provided the models.py files are unchanged?
>
> Many thanks,
> Ben
>
> --
> 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.
>
>

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Jan. 25, 2011 15:46:39

M.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

copying sqlite database file between projects


The database tables are named {{app_label}}_{{model_name}}, so in order
to use the same database you will need to use the same application name
(or specify db_table in the model's Meta).

--
Michael <mhall...@gmail.com>

On Tue, 2011-01-25 at 07:36 -0800, Ben Dembroski wrote:
> Hi all,
>
> Afraid I've got another newbie question. I've been doing some
> development on a project using sqlite3. All is working well, and I'd
> like to use the same database file in another project, data intact.
> I've copied the database file, and the models.py file to the
> appropriate locations in the new project. When I run syncdb, the
> only result is 'no fixtures found.'
>
> When I pop into the shell, all the fields are there, but I can't get
> to the data in any of them.
>
> For instance, inside the shell for the new project I run:
>
> Person.objects.all()
>
> it returns
>
>
>
> Do I need to do something besides just copying the database file to
> keep my data, provided the models.py files are unchanged?
>
> Many thanks,
> Ben
>

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#4 Jan. 25, 2011 15:46:51

Jonas G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

copying sqlite database file between projects


> 've copied the database file, and the models.py file to the
> appropriate locations in the new project.

Have you adjusted the settings.py database settings to the correct values ?
If so, maybe try the full path to your database file.

Regards,

Jonas.






--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#5 Jan. 25, 2011 15:47:42

Javier G.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

copying sqlite database file between projects


On Tue, Jan 25, 2011 at 10:36 AM, Ben Dembroski <i...@ionraystudios.com> wrote:
> When I run syncdb, the
> only result is 'no fixtures found.'

in Django-speak 'fixtures' are external files with data to be inserted
in the database, could be in XML, JSON or YAML. do you use them?
maybe you should copy those too from your old project to the new

--
Javier

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#6 Jan. 25, 2011 16:02:09

Ben D.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

copying sqlite database file between projects


Thanks.

I suspect this is the issue, as I just changed the settings.py file on
the original project to point to the copied database file. It has no
problem accessing the data. I'll play around with the meta settings
and see what I can come up with.

Thanks!



On Jan 25, 3:46 pm, Michael <mhall...@gmail.com> wrote:
> The database tables are named {{app_label}}_{{model_name}}, so in order
> to use the same database you will need to use the same application name
> (or specify db_table in the model's Meta).
>
> --
> Michael <mhall...@gmail.com>
>
>
>
>
>
>
>
> On Tue, 2011-01-25 at 07:36 -0800, Ben Dembroski wrote:
> > Hi all,
>
> > Afraid I've got another newbie question.   I've been doing some
> > development on a project using sqlite3.  All is working well, and I'd
> > like to use the same database file in another project, data intact.
> > I've copied the database file, and the models.py file to the
> > appropriate locations in the new project.   When I run syncdb, the
> > only result is 'no fixtures found.'
>
> > When I pop into the shell, all the fields are there, but I can't get
> > to the data in any of them.
>
> > For instance, inside the shell for the new project I run:
>
> > Person.objects.all()
>
> > it returns
>
> >
>
> > Do I need to do something besides just copying the database file to
> > keep my data, provided the models.py files are unchanged?
>
> > Many thanks,
> > Ben

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#7 Jan. 25, 2011 16:33:57

Ben D.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

copying sqlite database file between projects


Attempting to add the db_table name to the model made things a bit
more confusing.

The original app's name was 'sample_app' (not my choosing)

The app that I'm trying to get to access the data is 'trajectories'



I just added the following the Meta class for one of the models:


class Meta:
db_table = 'sample_app_Person'

and got the following when I ran syncdb:
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/
__init__.py", line 438, in execute_manager
utility.execute()
File "/usr/local/lib/python2.6/dist-packages/django/core/management/
__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/
base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/
base.py", line 220, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/
base.py", line 351, in handle
return self.handle_noargs(**options)
File "/usr/local/lib/python2.6/dist-packages/django/core/management/
commands/syncdb.py", line 95, in handle_noargs
cursor.execute(statement)
File "/usr/local/lib/python2.6/dist-packages/django/db/backends/
util.py", line 15, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.6/dist-packages/django/db/backends/
sqlite3/base.py", line 200, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.DatabaseError: table "sample_app_Person" already
exists

If I run the shell, and try to get to the data, I get this:

(InteractiveConsole)
>>> from trajectories.models import Person
>>> Person.objects.all()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python2.6/dist-packages/django/db/models/
query.py", line 67, in __repr__
data = list(self)
File "/usr/local/lib/python2.6/dist-packages/django/db/models/
query.py", line 82, in __len__
self._result_cache.extend(list(self._iter))
File "/usr/local/lib/python2.6/dist-packages/django/db/models/
query.py", line 271, in iterator
for row in compiler.results_iter():
File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/
compiler.py", line 677, in results_iter
for rows in self.execute_sql(MULTI):
File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/
compiler.py", line 732, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python2.6/dist-packages/django/db/backends/
util.py", line 15, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.6/dist-packages/django/db/backends/
sqlite3/base.py", line 200, in execute
return Database.Cursor.execute(self, query, params)
DatabaseError: no such column: sample_app_Person.dobestm

Any ideas ?

Thanks again!

On Jan 25, 4:02 pm, Ben Dembroski <i...@ionraystudios.com> wrote:
> Thanks.
>
> I suspect this is the issue, as I just changed the settings.py file on
> the original project to point to the copied database file.   It has no
> problem accessing the data.  I'll play around with the meta settings
> and see what I can come up with.
>
> Thanks!
>
> On Jan 25, 3:46 pm, Michael <mhall...@gmail.com> wrote:
>
>
>
>
>
>
>
> > The database tables are named {{app_label}}_{{model_name}}, so in order
> > to use the same database you will need to use the same application name
> > (or specify db_table in the model's Meta).
>
> > --
> > Michael <mhall...@gmail.com>
>
> > On Tue, 2011-01-25 at 07:36 -0800, Ben Dembroski wrote:
> > > Hi all,
>
> > > Afraid I've got another newbie question.   I've been doing some
> > > development on a project using sqlite3.  All is working well, and I'd
> > > like to use the same database file in another project, data intact.
> > > I've copied the database file, and the models.py file to the
> > > appropriate locations in the new project.   When I run syncdb, the
> > > only result is 'no fixtures found.'
>
> > > When I pop into the shell, all the fields are there, but I can't get
> > > to the data in any of them.
>
> > > For instance, inside the shell for the new project I run:
>
> > > Person.objects.all()
>
> > > it returns
>
> > >
>
> > > Do I need to do something besides just copying the database file to
> > > keep my data, provided the models.py files are unchanged?
>
> > > Many thanks,
> > > Ben

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#8 Jan. 25, 2011 16:36:41

M.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

copying sqlite database file between projects


I believe table names are all lower-case, so try 'sample_app_person'
--
Michael <mhall...@gmail.com>

On Tue, 2011-01-25 at 08:33 -0800, Ben Dembroski wrote:
> Attempting to add the db_table name to the model made things a bit
> more confusing.
>
> The original app's name was 'sample_app' (not my choosing)
>
> The app that I'm trying to get to access the data is 'trajectories'
>
>
>
> I just added the following the Meta class for one of the models:
>
>
> class Meta:
> db_table = 'sample_app_Person'
>
> and got the following when I ran syncdb:
> Traceback (most recent call last):
> File "manage.py", line 11, in <module>
> execute_manager(settings)
> File "/usr/local/lib/python2.6/dist-packages/django/core/management/
> __init__.py", line 438, in execute_manager
> utility.execute()
> File "/usr/local/lib/python2.6/dist-packages/django/core/management/
> __init__.py", line 379, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
> File "/usr/local/lib/python2.6/dist-packages/django/core/management/
> base.py", line 191, in run_from_argv
> self.execute(*args, **options.__dict__)
> File "/usr/local/lib/python2.6/dist-packages/django/core/management/
> base.py", line 220, in execute
> output = self.handle(*args, **options)
> File "/usr/local/lib/python2.6/dist-packages/django/core/management/
> base.py", line 351, in handle
> return self.handle_noargs(**options)
> File "/usr/local/lib/python2.6/dist-packages/django/core/management/
> commands/syncdb.py", line 95, in handle_noargs
> cursor.execute(statement)
> File "/usr/local/lib/python2.6/dist-packages/django/db/backends/
> util.py", line 15, in execute
> return self.cursor.execute(sql, params)
> File "/usr/local/lib/python2.6/dist-packages/django/db/backends/
> sqlite3/base.py", line 200, in execute
> return Database.Cursor.execute(self, query, params)
> django.db.utils.DatabaseError: table "sample_app_Person" already
> exists
>
> If I run the shell, and try to get to the data, I get this:
>
> (InteractiveConsole)
> >>> from trajectories.models import Person
> >>> Person.objects.all()
> Traceback (most recent call last):
> File "<console>", line 1, in <module>
> File "/usr/local/lib/python2.6/dist-packages/django/db/models/
> query.py", line 67, in __repr__
> data = list(self)
> File "/usr/local/lib/python2.6/dist-packages/django/db/models/
> query.py", line 82, in __len__
> self._result_cache.extend(list(self._iter))
> File "/usr/local/lib/python2.6/dist-packages/django/db/models/
> query.py", line 271, in iterator
> for row in compiler.results_iter():
> File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/
> compiler.py", line 677, in results_iter
> for rows in self.execute_sql(MULTI):
> File "/usr/local/lib/python2.6/dist-packages/django/db/models/sql/
> compiler.py", line 732, in execute_sql
> cursor.execute(sql, params)
> File "/usr/local/lib/python2.6/dist-packages/django/db/backends/
> util.py", line 15, in execute
> return self.cursor.execute(sql, params)
> File "/usr/local/lib/python2.6/dist-packages/django/db/backends/
> sqlite3/base.py", line 200, in execute
> return Database.Cursor.execute(self, query, params)
> DatabaseError: no such column: sample_app_Person.dobestm
>
> Any ideas ?
>
> Thanks again!
>
> On Jan 25, 4:02 pm, Ben Dembroski <i...@ionraystudios.com> wrote:
> > Thanks.
> >
> > I suspect this is the issue, as I just changed the settings.py file on
> > the original project to point to the copied database file. It has no
> > problem accessing the data. I'll play around with the meta settings
> > and see what I can come up with.
> >
> > Thanks!
> >
> > On Jan 25, 3:46 pm, Michael <mhall...@gmail.com> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > The database tables are named {{app_label}}_{{model_name}}, so in order
> > > to use the same database you will need to use the same application name
> > > (or specify db_table in the model's Meta).
> >
> > > --
> > > Michael <mhall...@gmail.com>
> >
> > > On Tue, 2011-01-25 at 07:36 -0800, Ben Dembroski wrote:
> > > > Hi all,
> >
> > > > Afraid I've got another newbie question. I've been doing some
> > > > development on a project using sqlite3. All is working well, and I'd
> > > > like to use the same database file in another project, data intact.
> > > > I've copied the database file, and the models.py file to the
> > > > appropriate locations in the new project. When I run syncdb, the
> > > > only result is 'no fixtures found.'
> >
> > > > When I pop into the shell, all the fields are there, but I can't get
> > > > to the data in any of them.
> >
> > > > For instance, inside the shell for the new project I run:
> >
> > > > Person.objects.all()
> >
> > > > it returns
> >
> > > >
> >
> > > > Do I need to do something besides just copying the database file to
> > > > keep my data, provided the models.py files are unchanged?
> >
> > > > Many thanks,
> > > > Ben
>

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#9 Jan. 25, 2011 16:42:34

Ion R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

copying sqlite database file between projects


That solved the syncdb error, but I'm still getting the same errorinside the shell when I am trying get to the data.Progress!

Thanks again!


On 25/01/11 16:36, Michael wrote:I believe table names are all lower-case, so try 'sample_app_person'--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#10 Jan. 26, 2011 12:58:55

Ion R.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

copying sqlite database file between projects


Yup. That did it. The errors were a result of setttings.py pointing tothe wrong database.Too much mucking about with too many things at the same time...


On 25/01/11 16:36, Michael wrote:I believe table names are all lower-case, so try 'sample_app_person'--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » copying sqlite database file between projects [RSS Feed]

Board footer

Moderator control

Enjoy the 17th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support