Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django - too many options when lanuching dbshell sqlite3

Tags:

sqlite

django

I have django 1.2.3.0 Final and I am using Python 2.7

In my setting, I have 'sqlite3' filled for the DATABASE_ENGINE. I am able to work with the sqlite3 (at the level of djano manage.py shell) until I am told that I need to access

python manage.py dbshell

At first I got the error "sqlite3 is not recognized...." Then I read threads and I found that this can be solved by downloading the exe file and set the environment variable path on Windows (I am on XP Pro)

I used this approach instead http://groups.google.com/group/django-users/msg/cf0665c227030ae2?

Now when I access python manage.py dbshell, I am getting

C:\Documents and Settings\JohnWong\workspace\mysite\mysite>python
manage.py dbsh
ell
sqlite3: Error: too many options: "Settings\JohnWong\workspace\mysite
\sqlite.db"

Use -help for a list of options.

I tried with --database=name_of_my_db and still no luck

Any input is appreciated. Thanks

like image 790
CppLearner Avatar asked Jan 02 '26 07:01

CppLearner


1 Answers

The root problem (still there in django 1.3.1) is that the code that execs the sqlite3 client doesn't deal with spaces in the sqlite db pathname. I added some quotes as follows:

django.db.backends.sqlite3/client.py

class DatabaseClient(BaseDatabaseClient):
        executable_name = 'sqlite3'

        def runshell(self):
            args = [self.executable_name,
                    '"' + self.connection.settings_dict['NAME'] + '"'] # JA HACK 
            if os.name == 'nt':
                sys.exit(os.system(" ".join(args)))
            else:
                os.execvp(self.executable_name, args)

and it now works for me (only tested Windows - os.name 'nt').

like image 163
John Armstrong Avatar answered Jan 04 '26 01:01

John Armstrong



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!