Agile Technologies and Sqlalchemy
Agile Technologies and Sqlalchemy
and SQLAlchemy
Christopher Perkins
PyWorks 2008
What is Agile?
Adaptive
http://www.flickr.com/photos/roblee/442358096/
Collaborative
http://www.flickr.com/photos/gaetanlee/159591865/
Testing
http://www.flickr.com/photos/alisdair/135306281/
What does Python
offer?
Virtualenv
http://www.flickr.com/photos/trommetter/128400664/
Paster
http://www.flickr.com/photos/eastlothian/419836784/
Portability
http://www.flickr.com/photos/23072179@N00/2271722618/
And Now For Something
Completely Different
Courtesy xkcd.com
Thank God for
Python…
Testing
Nose
http://www.flickr.com/photos/cobalt/2373422066/
Test Discovery
Coverage
http://www.flickr.com/photos/stian_olsen/2836208345/
Why Test a Database
Schema?
Because it’s there
+
Declarative
Example Model
from sqlalchemy import *
from sqlalchemy.orm *
from sqlalchemy.ext.declarative import declarative_base
metadata = MetaData()
Base = declarative_base(metadata=metadata)
class DBObject(object):
def __init__(self, **kw):
for item, value in kw.iteritems():
setattr(self, item, value)
database_created = False
def setup_database():
global database_created
engine = create_engine(os.environ.get('DBURL', 'sqlite://'))
metadata.bind = engine
if not database_created:
metadata.drop_all()
metadata.create_all()
database_created = True
’
Your Database will
Change
SQLAlchemy Migrate
http://farm1.static.flickr.com/73/170412399_a6c89b8dff.jpg?v=0
Version Control
Upgrade
Downgrade
Documentation
Robustness
http://farm3.static.flickr.com/2029/2229405391_a07aa5b5eb.jpg?v=0
Thanks!
Links
Python Tutorials
http://code.google.com/p/pythontutorials/
This Presentation
http://pythontutorials.googlecode.com/svn/presentations/AgileSA.ppt
Barbershop Tutorial
svn checkout
http://pythontutorials.googlecode.com/svn/tutorials/barbershop
Me
www.percious.com