← Back to team overview

openstack team mailing list archive

Unable to connect to MYSQL DB using inbuilt session provided by openstack

 

Hi All,

I want to use the existing engine created by Openstack to connect to
the MYSQL Database, however somehow I am not able to connect. .

The existing engine gets connected to SQLite database(which is the
default db) and not MYSQL.

I got the Openstack session and engine from :
from nova.openstack.common.db.sqlalchemy import session as db_session

get_session = db_session.get_session
session = get_session()

get_engine = db_session.get_engine
engine=get_engine()



This is inbuilt session info of Openstack :

{'autocommit': True, 'autoflush': True, 'transaction': None,
'hash_key': 1L, 'expire_on_commit': False, '_new': {}, 'bind':
Engine(sqlite:////opt/stack/nova/nova/openstack/common/db/nova.sqlite),
'_deleted': {}, '_flushing': False, 'identity_map': {},
'_enable_transaction_accounting': True, '_identity_cls': <class
'sqlalchemy.orm.identity.WeakInstanceDict'>, 'twophase': False,
'_Session__binds': {}, '_query_cls': <class
'nova.openstack.common.db.sqlalchemy.session.Query'>}



Then Manully created session and engine and able to connect to db and query it
The Manualy created session info is:

{'autocommit': False, 'autoflush': True, 'transaction':
<sqlalchemy.orm.session.SessionTransaction object at 0xa2fe34c>,
'hash_key': 1L, 'expire_on_commit': True, '_new': {}, 'bind':
Engine(mysql://username:passworsd@hostip/nova), '_deleted': {},
'_flushing': False, 'identity_map': {},
'_enable_transaction_accounting': True, '_identity_cls': <class
'sqlalchemy.orm.identity.WeakInstanceDict'>, 'twophase': False,
'_Session__binds': {}, '_query_cls': <class
'sqlalchemy.orm.query.Query'>}


Please let me know how to proceed further.Any help is appreciated.

Thanks,
Swapnil


Follow ups