Installed SQLAlchemy: easy_install SQLAlchemy
Trying the tutorial at http://docs.pythonweb.org/display/pylonscookbook/Making+a+Pylons+Blog
Did all steps without incident using sqlite and the MyBlog folder name, etc. and the “blog” works fine. Where is the SQL magic happening? In the blog controller (blog.py) in its index function:
q = model.Session.query(model.Blog)
c.posts = q.limit(5)
return render("/blog/index.html")
Now looking at sqlautocode, which needs pymssql. Found and installed (using .zip for Python 2.5). Modified autocode so I didn’t have to use command line, see below. One problem was that the tables in the database were NOT in the default dbo schema, but in “myschema” (another name actually), so had to specify this:
#File autocode.py
import sqlautocode
command = "mssql://sqlusername:sqlpass@sqlserver.dummy.net/sqldatabase -s myschema -t tablewildcard* --noindexes --output out.py"
argv = ("autocode "+command).split(" ")
sqlautocode.main(argv) #File sqlautocode\__init__.py
#def main(myargv):
# config.configure(myargv)
Tried it without –noindexes, but get “It seems that this dialect does not support indexes!” Foreign keys seem OK so far, and schema is passed in the output file.
Tags: sqlautocode