pyodbc has to be installed separately, see https://pypi.python.org/pypi/pyodbc/ 
<https://pypi.python.org/pypi/pyodbc/>




> On Nov 13, 2014, at 5:10 PM, Matthew Albert <[email protected]> wrote:
> 
> Hi,
> 
> I'm trying to make a connection to a 2012 MS SQL database using python 3.4 
> and SQLAlchemy/pyodbc.
> 
> I don't have pyodbc, but noticed that the install of SQLAlchemy included it.  
> I've copied my code below to select the first value from the table 
> 'Mezzanines'.  Please note the connection string:
> 'mssql+pyodbc://TheServer//TheDB'
> 
> Attempting to connection using windows authentication.
> 
> Traceback error shown below.  No module named 'pyodbc'.  Is this because 
> create_engine is trying to find module pyodbc in the sys.path?  Do I need to 
> put pyodbc in the sys.path?
> 
> thx
> Matt
> 
> 
> ________________________________________________
> from sqlalchemy import create_engine
> from sqlalchemy.orm import sessionmaker
>  
> from sqlalchemy_declarative import Address, Base, Person
> from sqlalchemy.connectors import pyodbc
>  
> engine = create_engine('mssql+pyodbc://TheServer//TheDB')
> 
> Base.metadata.bind = engine
>  
> DBSession = sessionmaker(bind=engine)
> session = DBSession()
> 
> # Write the query
> mezz = session.query('Mezzanines').first()
> print(mezz.name)
> __________________________________________________
> 
> Traceback (most recent call last):
>   File "C:/Python34/Programs/SQLAlchemy Tutorial/sqlalchemy_insert.py", line 
> 7, in <module>
>     engine = create_engine('mssql+pyodbc://gtasfdm')
>   File "C:\Python34\lib\site-packages\sqlalchemy\engine\__init__.py", line 
> 362, in create_engine
>     return strategy.create(*args, **kwargs)
>   File "C:\Python34\lib\site-packages\sqlalchemy\engine\strategies.py", line 
> 74, in create
>     dbapi = dialect_cls.dbapi(**dbapi_args)
>   File "C:\Python34\lib\site-packages\sqlalchemy\connectors\pyodbc.py", line 
> 51, in dbapi
>     return __import__('pyodbc')
> ImportError: No module named 'pyodbc'
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sqlalchemy" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected] 
> <mailto:[email protected]>.
> To post to this group, send email to [email protected] 
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/sqlalchemy 
> <http://groups.google.com/group/sqlalchemy>.
> For more options, visit https://groups.google.com/d/optout 
> <https://groups.google.com/d/optout>.

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to