Issue 1:
Migrated issue, originally created by Anonymous

Without the foreign key, it works fine and with sqlite instead of postgres, it works fine too.

See attached file for a test case.

It fails with the following traceback:

Traceback (most recent call last):
File "test_autoload.py", line 20, in <module>
meta2.create_all() # this fails.
File "/home/ged/devel/sqlalchemy/lib/sqlalchemy/schema.py", line 1147, in create_all
connectable.create(self, checkfirst=checkfirst, tables=tables)
File "/home/ged/devel/sqlalchemy/lib/sqlalchemy/engine/base.py", line 681, in create
self._run_visitor(self.dialect.schemagenerator, entity, connection=connection, **kwargs)
File "/home/ged/devel/sqlalchemy/lib/sqlalchemy/engine/base.py", line 711, in _run_visitor
element.accept_visitor(visitorcallable(conn, **kwargs))
File "/home/ged/devel/sqlalchemy/lib/sqlalchemy/schema.py", line 1169, in accept_visitor
visitor.visit_metadata(self)
File "/home/ged/devel/sqlalchemy/lib/sqlalchemy/ansisql.py", line 805, in visit_metadata
table.accept_visitor(self)
File "/home/ged/devel/sqlalchemy/lib/sqlalchemy/sql.py", line 2095, in accept_visitor
visitor.visit_table(self)
File "/home/ged/devel/sqlalchemy/lib/sqlalchemy/ansisql.py", line 840, in visit_table
self.execute()
File "/home/ged/devel/sqlalchemy/lib/sqlalchemy/engine/base.py", line 1179, in execute
return self.connection.execute(self.buffer.getvalue())
File "/home/ged/devel/sqlalchemy/lib/sqlalchemy/engine/base.py", line 502, in execute
return Connection.executors[c](c)(self, object, *multiparams, **params)
File "/home/ged/devel/sqlalchemy/lib/sqlalchemy/engine/base.py", line 517, in execute_text
self._execute_raw(context)
File "/home/ged/devel/sqlalchemy/lib/sqlalchemy/engine/base.py", line 566, in _execute_raw
self._execute(context)
File "/home/ged/devel/sqlalchemy/lib/sqlalchemy/engine/base.py", line 583, in _execute
raise exceptions.SQLError(context.statement, context.parameters, e)
sqlalchemy.exceptions.SQLError: (ProgrammingError) syntax error at or near "$1"
LINE 6: CONSTRAINT $1 FOREIGN KEY(test_id) REFERENCES test (id)
^
"\nCREATE TABLE test (\n\tid INTEGER DEFAULT nextval('public.test_id_seq'::text) NOT NULL, \n\ttest_id INTEGER, \n\tPRIMARY KEY (id), \n\t CONSTRAINT $1 FOREIGN KEY(test_id) REFERENCES test (id)\n)\n\n" {}

Issue 2:
Migrated issue, originally created by Anonymous

I searched existing open issues tagged with mssql but didn't see this one. Please close it if it's a duplicate.

~Matt

Pylons 0.9.7, SQLAlchemy 0.5.x, OSX 10.5, iodbc, freetds, remote MSSQL Server instance

test.py contains:

engine = create_engine("mssql://mdoar:secretword@hostname.example.com:1433/my_database?driver=TDS&odbc_options='TDS_Version=7.0'")

This breaks with the attached backtrace

meta = schema.MetaData(engine, reflect=True)

but this works fine:

meta = schema.MetaData(engine, reflect=False)

File "/Users/mdoar/atlassian/jira/commercial/venv_0.9.7/lib/python2.5/site-packages/SQLAlchemy-0.4.7p1-py2.5.egg/sqlalchemy/engine/base.py", line 907, in _execute_compiled

self.__execute_raw(context)

File "/Users/mdoar/atlassian/jira/commercial/venv_0.9.7/lib/python2.5/site-packages/SQLAlchemy-0.4.7p1-py2.5.egg/sqlalchemy/engine/base.py", line 916, in __execute_raw

self._cursor_execute(context.cursor, context.statement, context.parameters0, context=context)

File "/Users/mdoar/atlassian/jira/commercial/venv_0.9.7/lib/python2.5/site-packages/SQLAlchemy-0.4.7p1-py2.5.egg/sqlalchemy/engine/base.py", line 960, in _cursor_execute

self._handle_dbapi_exception(e, statement, parameters, cursor)

File "/Users/mdoar/atlassian/jira/commercial/venv_0.9.7/lib/python2.5/site-packages/SQLAlchemy-0.4.7p1-py2.5.egg/sqlalchemy/engine/base.py", line 942, in _handle_dbapi_exception

raise exceptions.DBAPIError.instance(statement, parameters, e, connection_invalidated=is_disconnect)

sqlalchemy.exceptions.ProgrammingError: (ProgrammingError) ('The SQL contains 0 parameter markers, but 1 parameters were supplied', 'HY000') u'SELECT tables_1.table_name \nFROM information_schema.tables AS tables_1 \nWHERE tables_1.table_schema = ?' 'dbo'

Attachments: add_flag.patch