Source

sqlalchemy / lib / sqlalchemy / dialects / mysql / gaerdbms.py

# mysql/gaerdbms.py
# Copyright (C) 2005-2012 the SQLAlchemy authors and contributors <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
# the MIT License: http://www.opensource.org/licenses/mit-license.php

"""Support for the MySQL database via the Google App Engine rdbms adapter.

Connecting
----------

from google.appengine.api import rdbms

def connect():
    return rdbms.connect(instance='[Cloud SQL Instance ID]', database='[Database Name]')

engine = sa.create_engine('mysql+gaerdbms://', creator=connect, echo=True, pool_recycle=3600)

MySQL-Python Compatibility
--------------------------

Anyone know?

Would this break anything?

"Note: The Python rdbms module supports only the %s format in parameter replacement.
Therefore, the following statement is invalid: cursor.execute('INSERT INTO entries
(guestAge) VALUES (%d)', (age))"

Issues
------

we don't appear to be trapping database exceptions correctly (assuming Google allows
us to trap database errors..). eg running:

Base.metadata.create_all(engine)

dies when it executes "describe `tablename`


"""

from google.appengine.api import rdbms

from sqlalchemy.dialects.mysql.mysqldb import MySQLDialect_mysqldb 

class MySQLDialect_gaerdbms(MySQLDialect_mysqldb): 
    driver = 'rdbms'

    description_encoding = None
    @classmethod 
    def dbapi(cls): 
        return rdbms

dialect = MySQLDialect_gaerdbms