The forum will experience an outage sometime between February 10 at 7:00pm EST and February 12 at 11:59 EST for installation of security updates. The actual time and duration of the outage are unknown but attempts will be made to minimize the downtime. We apologize for any inconvenience.

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': 'localhost',
                        '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

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

asked 14 Apr '14, 21:42

Elio%20Cl%C3%ADmaco%20Herrera's gravatar image

Elio Clímaco...
66349
accept rate: 100%

edited 15 Apr '14, 09:18

Mark%20Culp's gravatar image

Mark Culp
22.3k9129262


The problem is this line:

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

The '2638' should be the name of your server, which judging by your test_sqlany.py file should be "django". Replace it with:

'OPTIONS': {'eng': 'django'},
permanent link

answered 14 Apr '14, 22:13

Graeme%20Perrow's gravatar image

Graeme Perrow
8.4k369107
accept rate: 51%

Hi, Graeme Perrow thanks for the answer.

I, replaced

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

with

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

but another error raised

django.db.utils.OperationalError: Syntax error near ',' on line 1

I, check this thousands of times and I, can't see the error

Here is the complete text about this error

D:\mysite>python manage.py syncdb
Creating tables ...
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 112, in handle_noargs
    emit_post_sync_signal(created_models, verbosity, interactive, db)
  File "C:\Python27\lib\site-packages\django\core\management\sql.py", line 216,
in emit_post_sync_signal
    interactive=interactive, db=db)
  File "C:\Python27\lib\site-packages\django\dispatch\dispatcher.py", line 185,
in send
    response = receiver(signal=self, sender=sender, **named)
  File "C:\Python27\lib\site-packages\django\contrib\auth\management\__init__.py
", line 101, in create_permissions
    auth_app.Permission.objects.using(db).bulk_create(perms)
  File "C:\Python27\lib\site-packages\django\db\models\query.py", line 356, in b
ulk_create
    self._batched_insert(objs_without_pk, fields, batch_size)
  File "C:\Python27\lib\site-packages\django\db\models\query.py", line 835, in _
batched_insert
    using=self.db)
  File "C:\Python27\lib\site-packages\django\db\models\manager.py", line 232, in
 _insert
    return insert_query(self.model, objs, fields, **kwargs)
  File "C:\Python27\lib\site-packages\django\db\models\query.py", line 1511, in
insert_query
    return query.get_compiler(using=using).execute_sql(return_id)
  File "C:\Python27\lib\site-packages\django\db\models\sql\compiler.py", line 89
8, in execute_sql
    cursor.execute(sql, params)
  File "C:\Python27\lib\site-packages\django\db\backends\util.py", line 69, in e
xecute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "C:\Python27\lib\site-packages\django\db\backends\util.py", line 53, in e
xecute
    return self.cursor.execute(sql, params)
  File "C:\Python27\lib\site-packages\django\db\utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "C:\Python27\lib\site-packages\django\db\backends\util.py", line 53, in e
xecute
    return self.cursor.execute(sql, params)
  File "C:\Python27\lib\site-packages\sqlany_django\base.py", line 87, in execut
e
    ret = self.cursor.execute(trace(query), trace(args))
  File "C:\Python27\lib\site-packages\sqlanydb.py", line 712, in execute
    self.executemany(operation, [parameters])
  File "C:\Python27\lib\site-packages\sqlanydb.py", line 683, in executemany
    bind_count = self.api.sqlany_num_params(self.stmt)
  File "C:\Python27\lib\site-packages\sqlanydb.py", line 617, in __stmt_get
    self.handleerror(*self.parent.error())
  File "C:\Python27\lib\site-packages\sqlanydb.py", line 611, in handleerror
    eh(self.parent, self, errorclass, errorvalue)
  File "C:\Python27\lib\site-packages\sqlanydb.py", line 340, in standardErrorHa
ndler
    raise errorclass(errorvalue)
django.db.utils.OperationalError: Syntax error near ',' on line 1
(14 Apr '14, 23:56) Elio Clímaco...
Replies hidden

'PORT': '2638', <= that comma is unnecessary

(15 Apr '14, 03:02) Martin
3

The fact that you're getting an error from opening a cursor means that the connection succeeded. The syntax error is in your SQL query.

(15 Apr '14, 08:47) Graeme Perrow
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×137
×30
×15
×3

question asked: 14 Apr '14, 21:42

question was seen: 2,043 times

last updated: 15 Apr '14, 09:18