I can't connect Django with SQL Anywhere 11 Database

494 views
Skip to first unread message

Elio Gerson Clímaco Herrera

unread,
Apr 14, 2014, 1:29:41 AM4/14/14
to django...@googlegroups.com

Hi everybody...

 

I need connect django with sql anywhere 11 database, i follow the instructions on the page "SQL Anywhere Django Driver" from github.

 

I created the database with this command

C:\>dbinit -z UCA django.db --> (database created successful)

 

I started the Database Server with command

C:\>dbsrv11 django.db  --> (database server started successful)

 

I created my project with

C:\>django-admin.py startproject mysite (at this point all it's ok)

 

I edit the file mysite/mysite/settings.py and I changed the DATABASES setting with this

 

DATABASES = {

    'default': {

                        'ENGINE': 'sqlany_django',

                        'NAME': 'django',

                        'USER': 'dba',

                        'PASSWORD': 'sql',

                        'OPTIONS': {'eng': '2638'},

                        'HOST': 'django',

                        'PORT': '2638',

    }

}

 

The problem is, when I want sync database using this command

 

c:/mysite>python manage.py syncdb

 

 I get "Database server not found" error.

 

Please help me, I don't know how resolve this problem

 

Even I test the connection with a file (test_sqlany.py) this file contents following code

 

import sqlanydb

conn = sqlanydb.connect(uid='dba', pwd='sql', eng='django', dbn='django')

curs = conn.cursor()

curs.execute("select 'Hello, world!'")

print "SQL Anywhere says: %s" % curs.fetchone()

curs.close()

conn.close()

 

I, get get the expected output:

 

c:\>python test_sqlany.py

SQL Anywhere says: Hello, world!

 

I have an environment for test with this caracteristics

O.S.: Windows XP

DB Engine: SQL Anywhere 11 with EBF 3069

Python 2.7

Django 1.6.1

Setuptools installed

PIP installed

sqlanydb installed

sqlany-django installed

 

Sorry my english is very bad :)

 

Here is the complete text about this error

 

Traceback (most recent call last):

  File "manage.py", line 10, in <module>

    execute_from_command_line(sys.argv)

  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 

399, in execute_from_command_line

    utility.execute()

  File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line

392, in execute

    self.fetch_command(subcommand).run_from_argv(self.argv)

  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 242,

 in run_from_argv

    self.execute(*args, **options.__dict__)

  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 285,

 in execute

    output = self.handle(*args, **options)

  File "C:\Python27\lib\site-packages\django\core\management\base.py", line 415,

 in handle

    return self.handle_noargs(**options)

  File "C:\Python27\lib\site-packages\django\core\management\commands\syncdb.py"

, line 57, in handle_noargs

    cursor = connection.cursor()

  File "C:\Python27\lib\site-packages\django\db\backends\__init__.py", line 157,

 in cursor

    cursor = self.make_debug_cursor(self._cursor())

  File "C:\Python27\lib\site-packages\sqlany_django\base.py", line 476, in _curs

or

    self.connection = Database.connect(**kwargs)

  File "C:\Python27\lib\site-packages\sqlanydb.py", line 459, in connect

    return Connection(args, kwargs)

  File "C:\Python27\lib\site-packages\sqlanydb.py", line 508, in __init__

    self.handleerror(*error)

  File "C:\Python27\lib\site-packages\sqlanydb.py", line 518, in handleerror

    eh(self, None, errorclass, errorvalue)

  File "C:\Python27\lib\site-packages\sqlanydb.py", line 340, in standardErrorHa

ndler

    raise errorclass(errorvalue)

sqlanydb.OperationalError: Database server not found

 

 

Vernon D. Cole

unread,
Apr 14, 2014, 2:43:08 PM4/14/14
to django...@googlegroups.com
You would be best advised to contact whoever supports that driver. Their contact information ought to be on their github site. My guess (as a maintainer of a different 3rd party Windows database driver) is that they have not upgraded to django 1.6 yet. But that's only a wild guess.
  The other strong possibility is that you have something wrong in your DATABASES dictionary, but only someone familiar with that driver would have an idea what.

Andreas Kuhne

unread,
Apr 14, 2014, 2:59:03 PM4/14/14
to django...@googlegroups.com
Just a wild guess here.

Checking your databases dictionary, you have set : 'HOST': 'django'. I am guessing your server is running on the same computer as your django server? In that case you should change the line to : 'HOST': 'localhost', or just delete the line entirely (default is localhost). In your example where you are successful, you didn't specify a host, and my guess is it defaults to localhost.

If that is not the case, make sure that the host 'django' is a valid hostname, something like : django.mydomain.com or dbserver.mydomain.com, where django or dbserver is the name of your database server and "mydomain.com" is your domain.

Regards,

Andréas


--
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 django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0898e08a-126c-437f-994f-d5a159f192ff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Elio Gerson Clímaco Herrera

unread,
Apr 14, 2014, 4:51:13 PM4/14/14
to django...@googlegroups.com
Thanks to Vernon and Andreas, for your answers,

Yes Andreas my server is running on the same computer as my django server
but I, changed my database settings like this and I, have the same error "Database server not found"

DATABASES = {
    'default': {
'ENGINE': 'sqlany_django',
'NAME': 'django',
'USER': 'dba',
'PASSWORD': 'sql',
'OPTIONS': {'eng': '2638'},
'HOST': 'localhost',
'PORT': '2638',
    }
}

Even I, test with different combinations of database settings like 

DATABASES = {
    'default': {
'ENGINE': 'sqlany_django',
'NAME': 'django',
'USER': 'dba',
'PASSWORD': 'sql',
'OPTIONS': {'eng': '2638'},
    }
}

So I, get the same error message

Here is complete text about this error, please help me

Andreas Kuhne

unread,
Apr 15, 2014, 3:54:51 AM4/15/14
to django...@googlegroups.com
Hi again,
Unfortunately I don't have any experience with sqlanywhere. However, I googled and came up with the following information: https://code.google.com/p/sqlany-django/wiki/GettingStarted. In your databases dict you specify 'OPTIONS': {'eng': '2638'}, I think that should be : 'OPTIONS': {'eng': 'django'}.

If that doesn't work, I'm afraid I can't help you!

Regards,

Andréas

--
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 django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

Ramón Carrillo

unread,
Apr 15, 2014, 3:58:25 AM4/15/14
to django...@googlegroups.com
Hi,

You should use exactly the same parameters from your test_sqlany.py in your DATABASES dictionary.

The sqlany-django documentation states that "(eg. ENG, which is required for client versions prior to v12.0.0)". In the DATABASES dictionary, you seem to misunderstand the ENG option with PORT.

Given this

sqlanydb.connect(uid='dba', pwd='sql', eng='django', dbn='django')

Your dictionary should be like this

DATABASES = {
   'default' : {
       'ENGINE': 'sqlany_django',
       'NAME': 'django',
       'USER': 'dba',
       'PASSWORD': 'sql',
       'OPTIONS': {'eng': 'django'}
Message has been deleted
Message has been deleted

Tameen Malik

unread,
Apr 18, 2014, 1:58:30 AM4/18/14
to django...@googlegroups.com
Elio -- Have you used  UTF-8


By default, with a UTF-8 database, MySQL will use the utf8_general_ci collation. This results in all string equality comparisons being done in a case-insensitive manner. That is, "Fred" and "freD" are considered equal at the database level. If you have a unique constraint on a field, it would be illegal to try to insert both "aa" and "AA" into the same column, since they compare as equal (and, hence, non-unique) with the default collation



Collation settings   in https://docs.djangoproject.com/en/dev/ref/databases/
Reply all
Reply to author
Forward
0 new messages