Please be aware that the content in SAP SQL Anywhere Forum will be migrated to the SAP Community in August and this forum will be retired.

import sqlanydb

params = {
    'uid': 'user',
    'pwd': '**********',
    'eng': 'servername',
    'dbn': 'databasename'

conexao = sqlanydb.connect(**params)
cursor = conexao.cursor()
query = 'select * from geempre'
retorno = cursor.fetchall()
for r in retorno:

C:\Users\bi01\Documents\GitHub\Intranet_Objetiva\venv\Scripts\python.exe C:\Users\bi01\Documents\GitHub\Intranet_Objetiva\Intranet_Obj\ 
Traceback (most recent call last):
  File "C:\Users\bi01\Documents\GitHub\Intranet_Objetiva\Intranet_Obj\", line 12, in <module>
    conexao = sqlanydb.connect(**params)
  File "C:\Users\bi01\Documents\GitHub\Intranet_Objetiva\venv\Lib\site-packages\", line 566, in connect
    return Connection(args, kwargs)
  File "C:\Users\bi01\Documents\GitHub\Intranet_Objetiva\venv\Lib\site-packages\", line 633, in __init__
  File "C:\Users\bi01\Documents\GitHub\Intranet_Objetiva\venv\Lib\site-packages\", line 644, in handleerror
    eh(self, None, errorclass, errorvalue, sqlcode)
  File "C:\Users\bi01\Documents\GitHub\Intranet_Objetiva\venv\Lib\site-packages\", line 383, in standardErrorHandler
    raise errorclass(errorvalue,sqlcode)
sqlanydb.OperationalError: (b'Database server not found', -100)

Process finished with exit code 1

asked 13 Dec '23, 13:11

davidcloss's gravatar image

accept rate: 0%

edited 14 Dec '23, 03:29

Volker%20Barth's gravatar image

Volker Barth

"Database server not found" means that the SQL Anywhere client was not able to find a server running called "servername" with a database mounted on the server called "databasename".

Can you describe how you started the SQL Anywhere database engine prior to trying to connect?

permanent link

answered 13 Dec '23, 13:49

Reg%20Domaratzki's gravatar image

Reg Domaratzki
accept rate: 36%

Hello, the data I posted is not correct because I don't want to share sensitive company information. However, with the same data, I can log in to the database using SQL Central, so I'm sure the data is correct. I have the following drivers installed on my computer: ['SQL Server', 'UltraLite 17', 'SQL Anywhere 16', 'SQL Anywhere 17', 'ODBC Driver 17 for SQL Server', 'UltraLite 16']. However, I couldn't connect using the pyodbc library.

The database is already running, and in the engine, I entered the server name. Is that correct?

(13 Dec '23, 14:04) davidcloss
Replies hidden

You haven't given us a lot of information to go on here. Let me try and attack this a different way. If I open up a DOS prompt the following commands work like a charm for me :

dbinit -mpl 3 -dba dba,sql databasename.db
dbspawn dbsrv17 -n servername databasename.db

The contents of are :

import sqlanydb

params = { 'uid': 'dba', 'pwd': 'sql', 'eng': 'servername', 'dbn': 'databasename' }
con = sqlanydb.connect( **params )
cur = con.cursor()
cur.execute('select count(*) from sysfile')
assert cur.fetchone()[0] > 0

Do the commands above work for you?

If no, please describe what goes wrong.

If yes, what is different in your real environment where it doesn't work?


(13 Dec '23, 15:01) Reg Domaratzki

I am using PYODBC and this connection string works (here I should define the driver name).

import pyodbc
from pyodbc import Cursor 
conn = pyodbc.connect('Driver={SQL Anywhere 17};Database=???;Server=???;UID=???;pwd=???')
cursor = conn.cursor().execute('select * from dummy')

BTW, your example code worked also worked for me, so the problem is probably in your environment.

permanent link

answered 14 Dec '23, 03:09

Baron's gravatar image

accept rate: 48%

edited 14 Dec '23, 03:19

Your answer
toggle preview

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 13 Dec '23, 13:11

question was seen: 470 times

last updated: 14 Dec '23, 03:29