Paul's Programming Notes     Archive     Feed     Github

Compress - Sybase ODBC

Sybase has a odbc parameter called "Compress" that is disabled by default. It's very useful if you're running queries on something with slow network transfer speeds and large datasets.

Compress = yes

This improve the performance of my query by about 40%.

[IM004] [unixODBC][Driver Manager]Driver's SQLAllocHandle on SQL_HANDLE_HENV failed (0) (SQLDriverConnect) - Ubuntu

The link to download SQLanywhere is here:

To install it, you need to unzip the file and run "./setup" in the top level directory in the unzipped folder.

I also installed: (use the .zip file on the left)

The first error message I received was:
sqlanydb.InterfaceError: Could not load dbcapi.  Tried: dbcapi.dll,,libdbcapi_r.dylib
Exception AttributeError: "'Root' object has no attribute 'api'" in <bound method Root.__del__ of <sqlanydb.Root object at 0x3061150>> ignored

This error is resolved by creating a file called "/etc/" and adding a line with "/opt/sqlanywhere12/lib64". Then you will need to run ldconfig -v.

The error message in the title occurred on Ubuntu because unixODBC was unable to find all of the libraries it needed to run.

This helped to find the issue:

strace -t -f -o trace_out.txt isql -v <DSN>< USERNAME> <PASSWORD>

It will show there are a bunch of missing files. The issue was resolved when isql was run from the /opt/sqlanywhere12/bin64 directory. This indicated that it's not looking in the right place for the library files. Run the following: export LD_LIBRARY_PATH='/opt/sqlanywhere12/lib64'

Not having the environmental variable above will also cause "sqlanydb.InterfaceError: dbcapi version 1 required." if you're using python's sqlanydb library.

It will give a "file not found" error if you try using bin32/lib32 files on a 64 bit system. Make sure you use the bin64/lib64 files in the "Driver=" fild in your /etc/odbc.ini file (if you're using a 64 bit system)!

Now you will receive an error saying "Parse error: DSN does not exist". You need to add an ODBC_INI environmental variable to where your DSNs are defined. I ran the following: export ODBC_INI='/etc/odbc.ini'

To make those variables we exported work system-wide and continue to work even after we log out:

  1. sudo nano /etc/environment
  2. Add:

These articles were helpful:

Get ID of edited item within WTforms validator - Flask-Admin

Heroku's Advantages Over Google App Engine


  • Postgres (you can even use pgAdmin to view your database)
  • Uses Git to push your application into production
  • More monitoring features and 3rd party apps
  • As long as your project uses one dyno, it runs for free (similar to google, but with a less confusing billing structure)
  • 10k row limit for your database before they start charging you $9 per month 

AttributeError: 'QuerySelectField' object has no attribute '_sa_instance_state'

I came across this error when I was trying to make a custom validator in Flask-Admin with wtforms form objects.

This code didn't work:
def location_must_not_conflict(form, field):
if Event.query.filter(Event.location == form.location).first():
raise wtforms.validators.ValidationError('Location conflicts with another request for the same venue.')

Because I was using form.location and not

This will work:
def location_must_not_conflict(form, field):
if Event.query.filter(Event.location ==
raise wtforms.validators.ValidationError('Location conflicts with another request for the same venue.')

Google Calendar Api bad request 400 - Python Authomatic Library

I was finally able to get the request to go through by adding a header saying it's json format. Here's an example:

requestbody = """
      "end": {
      "dateTime": "2014-05-18T01:35:00Z"
      "start": {
      "dateTime": "2014-05-18T01:35:00Z"
      "description": "test2",
      "location": "test venue",
      "summary": "test2"
response = authomatic.access(credentials, url, method='POST', headers={'Content-Type': 'application/json'}, body=requestbody)

Add user_id for modified_by field before save - Flask-Admin

In Flask-Admin, you can override the "on_model_change" function to to automatically populate a "modified_by" field in your model.

class LocationView(ModelView):
def on_model_change(self, form, model):
model.user_id =

admin = Admin(app)
admin.add_view(LocationView(Location, db.session, name="Locations"))

Favorite Flask Boilerplate/Skeleton/Templates

Those do a lot of the work of starting a new Flask project for you.

With cookiecutter flask, all you need to do to build a new project is: cookiecutter

As a warning, cookiecutter flask and overholt include a lot of stuff. I ended up not using it because it was too much work to change everything to work with oAuth.