replace all SQL queries with SQLAlchemy code

Bug #722979 reported by Christian Berendt
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Kevin L. Mitchell

Bug Description

At the moment there are a lot of raw SQL queries in the code. They should be replaced with code using SQLAlchemy.

---snip---
~/src/nova/trunk (bzr)-[trunk:709] % grep -r -i session.execute *
nova/db/sqlalchemy/api.py: result = session.execute('UPDATE fixed_ips SET instance_id = NULL, '
nova/db/sqlalchemy/api.py: session.execute('update instances set deleted=1,'
nova/db/sqlalchemy/api.py: session.execute('update security_group_instance_association '
nova/db/sqlalchemy/api.py: session.execute('update key_pairs set deleted=1 where user_id=:id',
nova/db/sqlalchemy/api.py: session.execute('update networks set project_id=NULL')
nova/db/sqlalchemy/api.py: session.execute('update volumes set deleted=1 where id=:id',
nova/db/sqlalchemy/api.py: session.execute('update export_devices set volume_id=NULL '
nova/db/sqlalchemy/api.py: session.execute('update iscsi_targets set volume_id=NULL '
nova/db/sqlalchemy/api.py: session.execute('update security_groups set deleted=1 where id=:id',
nova/db/sqlalchemy/api.py: session.execute('update security_group_instance_association '
nova/db/sqlalchemy/api.py: session.execute('update security_group_rules set deleted=1 '
nova/db/sqlalchemy/api.py: session.execute('update security_groups set deleted=1')
nova/db/sqlalchemy/api.py: session.execute('update security_group_rules set deleted=1')
nova/db/sqlalchemy/api.py: session.execute('delete from user_project_association '
nova/db/sqlalchemy/api.py: session.execute('delete from user_role_association '
nova/db/sqlalchemy/api.py: session.execute('delete from user_project_role_association '
nova/db/sqlalchemy/api.py: session.execute('delete from user_project_association '
nova/db/sqlalchemy/api.py: session.execute('delete from user_project_role_association '
nova/db/sqlalchemy/api.py: session.execute('delete from user_project_role_association where '
nova/db/sqlalchemy/api.py: session.execute('delete from consoles '
nova/db/sqlalchemy/api.py: session.execute('delete from zones '
---snap---

Related branches

Thierry Carrez (ttx)
Changed in nova:
importance: Undecided → Medium
status: New → Confirmed
Changed in nova:
assignee: nobody → Kevin L. Mitchell (klmitch)
Changed in nova:
assignee: Kevin L. Mitchell (klmitch) → Taku Fukushima (tfukushima)
status: Confirmed → In Progress
Revision history for this message
Kevin L. Mitchell (klmitch) wrote :

Hey! You stole my bug!

Seriously, you closer to having working code? I haven't worked with SQLAlchemy before and was researching it, intending this bug to be a good way of getting into the groove with it...but if you've got code now, then I guess I'll just have to swallow it and find something else to try...

Revision history for this message
Taku Fukushima (tfukushima) wrote :

Hi Kevin,

Really sorry for my mistake.
I am a newcomer for launchpad and I didn't know how to assign the bug.
I assigned me this bug as "in progress" for test but I couldn't withdraw it.

I am newcomer for SQLAlchemy too, and learnd it on the last weekend.
I replace all raw SQLs by SQLAlchemy codes.
However, I don't finish testing my code.
I'll attach my code.
(I can't attach .patch file for some reason... I'll attach my nova/db/sqlalchemy/api.py file.)

I also show you another person's code I patched.

- http://www.debian.or.jp/~yosshy/nova-bexar-patches/
- http://www.debian.or.jp/~yosshy/nova-bexar-patches/667.patch

Revision history for this message
Taku Fukushima (tfukushima) wrote :

Hi Kevin,

I realize that I sent mail to <email address hidden>, not to you.

from Taku Fukushima <email address hidden>
to Bug 722979 <email address hidden>
date Tue, Mar 8, 2011 at 1:42 PM
subject Re: [Bug 722979] Re: replace all SQL queries with SQLAlchemy code
mailed-by gmail.com
hide details 1:42 PM (12 hours ago)
Hi Kevin,

My name is Taku Fukushima and I'm a 1st year master student in Japan.

I got a mail below and know that you're fixing this bug.
I also try to fix this bug for the task of internship test and if you
would let me do, I'd like to fix this.

Of course, if you are completing this task, I'll find another one.

Revision history for this message
Kevin L. Mitchell (klmitch) wrote :

Heh. No worries. Newbies can hardly complain if other newbies accidentally mess up, since they're in the same boat :) I'll go ahead and take the bug back. I haven't looked at your attachments, but I'm sure they'll be very useful :)

Changed in nova:
assignee: Taku Fukushima (tfukushima) → Kevin L. Mitchell (klmitch)
Changed in nova:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in nova:
milestone: none → 2011.2
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.