SQL Anywhere 10 Introduction. SQL Anywhere 10.0. Last revised: October 2006. This document is available in PDF only: link to PDF file.
This package provides a python interface to the SQL Anywhere databaseserver. This interface conforms to PEP 249.
Requirements
Before installing the sqlanydb interface please make sure thefollowing components are installed on your system.
- Python 2.4 or greater (including Python 3.x)
- Python ctypes module if missing
- SQL Anywhere 10 or higher
Installing the sqlanydb module
![Anywhere Anywhere](http://www.kodyaz.com/images/sql/sybase-sql-anywhere-administration-tools.png)
Run the following command as an administrative user to installsqlanydb:
Alternatively, you can use pip:
Converter Functions
This library wraps around the sqlanydb
dbcapi
C library. When retrievingvalues from the database, the C API returns one of these types:- A_INVALID_TYPE
- A_BINARY
- A_STRING
- A_DOUBLE
- A_VAL64
- A_UVAL64
- A_VAL32
- A_UVAL32
- A_VAL16
- A_UVAL16
- A_VAL8
- A_UVAL8
Other types are returned as the above types. For example, the NUMERIC type isreturned as a string.
To have
sqlanydb
return a different or custom python object, you can registercallbacks with the sqlanydb
module, usingregister_converter(datatype, callback)
. Callback is a function that takesone argument, the type to be converted, and should return the converted value.Datatype is one of the DT_
variables present in the module.The types available to register a converter for:
- DT_NOTYPE
- DT_DATE
- DT_TIME
- DT_TIMESTAMP
- DT_VARCHAR
- DT_FIXCHAR
- DT_LONGVARCHAR
- DT_STRING
- DT_DOUBLE
- DT_FLOAT
- DT_DECIMAL
- DT_INT
- DT_SMALLINT
- DT_BINARY
- DT_LONGBINARY
- DT_TINYINT
- DT_BIGINT
- DT_UNSINT
- DT_UNSSMALLINT
- DT_UNSBIGINT
- DT_BIT
- DT_LONGNVARCHAR
For example, to have NUMERIC types be returned as a python Decimal object:
Testing the sqlanydb module
To test that the Python interface to SQL Anywhere is working correctlyfirst start the demo database included with your SQL Anywhereinstallation and then create a file named test_sqlany.py with thefollowing contents:
Run the test script and ensure that you get the expected output:
License
This package is licensed under the terms of the Apache License, Version 2.0. Seethe LICENSE file for details.
Feedback and Questions
For feedback on this project, or for general questions about using SQL Anywhereplease use the SQL Anywhere Forum at http://sqlanywhere-forum.sap.com/
Installation Guide This chapter describes how to configure your Sybase Adaptive Server Anywhere (ASA) and Sybase SQL Anywhere databases for use within the SilverStream Server environment as either a SilverMaster database or an application database.
For the latest information on supported database versions, see the SilverStream Application Server release notes. In Windows, you can access the release notes from the SilverStream program group or from SilverStream online help.
This chapter includes these sections:
- Overview of Sybase ASA and SQL Anywhere support
- Upgrading from SQL Anywhere 5.5
- Setting up a Sybase ASA or SQL Anywhere database
- Troubleshooting
SilverStream Version 3 includes a special authenticated version of Sybase Adaptive Server Anywhere (ASA) 6. An authenticated version means that it can only be used with SilverStream.
This authenticated version of Sybase ASA allows users that do not already use Sybase ASA to install it at the same time that they install SilverStream. This software is supplied in part because the SilverStream online help system and sample applications are stored in Sybase ASA databases (you can also run the SilverStream help from the file system if you don't want to install Sybase ASA). If you already have Sybase ASA installed, you do not need to install this authenticated version.
Earlier versions of SilverStream included authenticated versions of Sybase SQL Anywhere 5.5.
You can use either Sybase ASA 6 or SQL Anywhere 5.5 as your SilverMaster and as your application databases. For each DBMS, you can use the authenticated versions provided with SilverStream or full versions purchased from Sybase.
Where to go from here
- If you have been using SQL Anywhere 5.5 (probably because you are upgrading from a previous release of SilverStream), go to Upgrading from SQL Anywhere 5.5.
- If you have only Sybase ASA 6, go to Setting up a Sybase ASA or SQL Anywhere database.
Read this section if you have been using SQL Anywhere 5.5.
You can choose to:
- Continue using SQL Anywhere 5.5 only
- Use both ASA 6 and SQL Anywhere 5.5 on the same machine
- Upgrade to Sybase ASA 6 and not use SQL Anywhere 5.5 any longer
Using only SQL Anywhere 5.5
You can continue to use SQL Anywhere 5.5 databases with SilverStream Version 3. If you are upgrading from a previous release of SilverStream, simply specify your existing SQL Anywhere 5.5 SilverMaster when installing SilverStream and add your existing application databases to the server. You don't need to read the rest of this section.
But note that if you do not install Sybase ASA 6 you will not be able to look at the SilverStream sample applications or run help from the SilverHelp database.
For more information about setting up your SQL Anywhere 5.5 databases, see Setting up a Sybase ASA or SQL Anywhere database.
Using both Sybase ASA and SQL Anywhere on the same machine
If you want to use both Sybase ASA 6 and SQL Anywhere 5.5 on one machine, you must install them in different directories, and you must have the SQL Anywhere 5.5 directories on your path before the Sybase ASA 6 directories. This ensures that the proper files are used by SQL Anywhere 5.5. You can then access both Sybase ASA 6 and SQL Anywhere 5.5 databases on the same machine.
For more information about setting up your Sybase ASA and SQL Anywhere 5.5 databases, see Setting up a Sybase ASA or SQL Anywhere database.
Upgrading to Sybase ASA 6
If you want to use only Sybase ASA 6, you must upgrade your SQL Anywhere 5.5 database files (.db) to ASA 6 before you can use them with the authenticated version of ASA 6. If the databases are not upgraded, an Authentication violation will occur when you attempt to add the SQL Anywhere 5.5 databases to SilverStream.
NOTE If you upgrade a SQL Anywhere 5.5 database file to ASA 6, you can no longer use the database with SQL Anywhere 5.5, so back up your database files before doing the upgrade.
To upgrade SQL Anywhere 5.5. databases to ASA 6:
- Install Sybase ASA 6 from the SilverStream Installation program. You can choose all the defaults.
- From the Adaptive Server Anywhere program group select Manage Adaptive Server Anywhere. Sybase Central opens.
- Select Upgrade Database from the Adaptive Server Anywhere Utilities list.
- Browse to the SQL Anywhere 5.5 database you wish to upgrade.
- If you wish to connect to this database with the Adaptive Server Anywhere ODBC driver, you must create an ODBC datasource for this newly upgraded database. It is recommended that the old SQL Anywhere 5.5 data source name (DSN) be deleted before doing this and the same DSN name be used for the ASA 6 version of this datasource.
- Add the database to the SilverStream server as a Sybase ASA 6 database.
For more information about setting up your Sybase ASA 6 databases, see Setting up a Sybase ASA or SQL Anywhere database next.
This section describes how to set up either Sybase ASA 6 or SQL Anywhere 5.5 databases to use with SilverStream.
Using Sybase Adaptive Server Anywhere
You can install the authenticated version of Sybase ASA from the SilverStream Installation program, which launches the Sybase ASA installation program. You can follow the Sybase ASA wizard and choose all the defaults (including to install the Personal Server edition of Sybase ASA). The installation wizard installs the Sybase ASA for use with SilverStream.
SilverStream connects to Sybase ASA using ODBC or jConnect. The Sybase ODBC driver and jConnect are included as part of the Sybase ASA installation.
- To use Sybase ASA for your SilverMaster, all you need to do is install Sybase ASA before installing SilverStream. When you install SilverStream, specify that you want to use Sybase ASA as your SilverMaster. The SilverStream installation program will create and configure the SilverMaster database for you (if you ask it to). It will create and use an ODBC connection.
- To use Sybase ASA for an application database, you need to set up the database yourself as described in the next section. When you add the database to the SilverStream server, you specify whether you want to use ODBC or jConnect.
Using Sybase SQL Anywhere
If you are using Sybase SQL Anywhere as your SilverMaster or as an application database, you need to set up the database yourself as described in the next section.
Setting up a SQL Anywhere or Sybase ASA database
To set up a Sybase ASA database as an application database or to set up a SQL Anywhere database for use as a SilverMaster or as an application database, do the following:
- Create a database using Sybase Central.
- Create a user account to be used by the SilverStream Server
- Create an ODBC System DSN entry for the database (if you are using ODBC for the database connection).
- Configure Sybase ASA or SQL Anywhere to run as a service. Sybase ASA or SQL Anywhere must be running when you install SilverStream if you want to use an existing database as your SilverMaster.
- Install SilverStream. For information about installing the SilverStream Server, see Installing SilverStream on Windows.
Step 1: Create a database
Before you can install SilverStream, you must first create the actual database and its underlying devices. Use Sybase Central to create the database.
For more information, see the Sybase Central online help.
Step 2: Create user accounts
Sybase ASA and SQL Anywhere provide a default user dba with the password sql. You can use this user name and password pair for your SilverMaster catalog or any other Sybase ASA or SQL Anywhere databases.
However, SilverStream strongly recommends that you set up a different account for your SilverMaster and for each application database so you can easily tell which applications are hitting your database when and how often, and you can more easily troubleshoot performance problems. For Sybase ASA and SQL Anywhere, make sure this account has at least Resource and Connect privileges.
For more information about setting up user accounts, see the Sybase Central online help.
Step 3: Create the ODBC System DSN entry
If you will be connecting to the database using ODBC (this is a requirement for SQL Anywhere; with Sybase ASA, you can use jConnect), you need to create an ODBC entry for the database.
For more information, see Creating ODBC Data Sources.
Step 4: Run Sybase ASA or SQL Anywhere as a service
SilverStream recommends that you run your Sybase ASA or SQL Anywhere databases as a service to make database use and maintenance easier.
For information about running Sybase ASA as a service, see the Sybase ASA online help: Select Start>Programs>Sybase>Adaptive Server Anywhere version>Adaptive Server Anywhere Manual. In the help contents, select ASA User's Guide. Go to 'Running the server outside the current session' in Part 1, Chapter 1.
For information about running SQL Anywhere as a service, see the SQL Anywhere online help: Select Start>Programs>Sybase SQL Anywhere 5.0>Sybase SQL Anywhere Manual. In the help contents, select SQL Anywhere User's Guide. Go to Chapter 29, Running Programs as Services,' in Part 3.
This section describes known problems and workarounds for SQL Anywhere in the SilverStream Server environment.
Memory leak
SQL Anywhere versions 5.5.02, 5.5.03, and 5.5.04 were affected by a memory leak that caused SQL Anywhere to allocate an abnormal amount of RAM during certain operations. This problem has been known to occur with the SilverStream Server under certain conditions. Contact Sybase for a fix.
Authentication violation
If you are receiving an Authentication violation when adding an Adaptive Server Anywhere database, check to make sure you have run the ASA 6 upgrade utility if the database had been created in SQL Anywhere 5.5.
Also, if you have both ASA 6 and SQL Anywhere 5.5 on the same machine, you might have a path problem. Ensure that the SQL Anywhere 5.5 directories are before the ASA 6 directories on the path, as described in Using both Sybase ASA and SQL Anywhere on the same machine. If this doesn't solve the problem, try renaming dbl50t.dll in the ASA win32 directory.
Copyright © 2000, SilverStream Software, Inc. All rights reserved.