Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I am attempting to create a python script that connects to an SQLITE database and using SQLAlchemy to help with this.
I am still very early, but am trying to create a connection to a new database but keep getting this "create_engine" is not defined in SQLAlchemy error.
To try to simplify I opened a python terminal to try it... see below:
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlalchemy
>>> engine = create_engine('sqlite:///test.db')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'create_engine' is not defined
>>> print(sqlalchemy.__version__)
1.3.18
At this point I don't even know where to go looking for the problem.
I did a pip uninstall sqlalchemy then pip install sqlalchemy hoping this might help.
–
Thanks to Gord Thompson. Changing this line:
engine = create_engine('sqlite:///test.db')
engine = db.create_engine('sqlite:///test.db')
made it work!!
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.