Search code examples
pythonsql-serverpeewee

Trying to connect to Microsoft SQL database with Peewee (python)


I'm trying to connect to a Microsoft SQL database using peewee and peewee-mssql. I've installed peewee version 3.10 and peewee-mssql version 0.1.3. I have tried running it with both Python 3.5 and Python 3.7, with the same result.

When I run this script:

import peewee as pw
from peewee_mssql import MssqlDatabase

db = MssqlDatabase('DATABASE INFO')

db.connect()

tables = db.get_tables()

for t in tables:
    print(t)

It gives me an error with this traceback:

  File "D:\test.py", line 2, in <module>
    from peewee_mssql import MssqlDatabase
  File "C:\Envs\TestEnv\lib\site-packages\peewee_mssql.py", line 1, in <module>
    from peewee import Database, ImproperlyConfigured, OP, QueryCompiler, CompoundSelect, SQL, Clause, CommaClause
ImportError: cannot import name 'QueryCompiler'

Am I using incompatible versions or something?

Thanks a lot, Alex


Solution

  • peewee-mssql is not compatible with Peewee 3.x and probably hasn't been updated in a long time.