On Monday, December 24, 2018 at 4:27:51 PM UTC-5, Brandon Arias wrote: > > I am new to SQLAlchemy. I believe I installed SQLAlchemy correctly since > just needed to install SQL. However once I tried creating an engine and > checking the tables under the most generic example, I kept getting empty > tables. And I was just following a simple tutorial from two sources. Also, > I did try to connect to other sqlite databases but I kept getting empty > tables. May I get some help? I just wanna be a nerd and enjoy databases :/ > > > http://shichaoji.com/2017/02/16/manipulate-database-basic-1-queries-and-sqlalchemy/ > > > https://towardsdatascience.com/sqlalchemy-python-tutorial-79a577141a91 > > !pip install SQLAlchemy > > ------ > import sqlalchemy as db > from sqlalchemy import create_engine > > engine = db.create_engine('sqlite:///census.sqlite',echo=True) > print(engine.table_names()) > > ----- > > 2018-12-24 15:24:41,596 INFO sqlalchemy.engine.base.Engine SELECT CAST('test > plain returns' AS VARCHAR(60)) AS anon_1 > 2018-12-24 15:24:41,601 INFO sqlalchemy.engine.base.Engine () > 2018-12-24 15:24:41,613 INFO sqlalchemy.engine.base.Engine SELECT CAST('test > unicode returns' AS VARCHAR(60)) AS anon_1 > 2018-12-24 15:24:41,615 INFO sqlalchemy.engine.base.Engine () > 2018-12-24 15:24:41,622 INFO sqlalchemy.engine.base.Engine SELECT name FROM > sqlite_master WHERE type='table' ORDER BY name > 2018-12-24 15:24:41,624 INFO sqlalchemy.engine.base.Engine () > > [] > > > > > This has to be something with the way I loaded or things that I still have > not downloaded. I tried uninstalling SQLAlchemy, but nothing > > Unfortunately the tutorials you read seem to be incomplete. The "db.create_engine()" call does not create anything in the SQLite database. Your "census.sqlite" database currently has no tables at all. If you are not currently familiar with creating and populating SQLite databases, I suggest you learn about that using the sqlite command first. When you want to learn SQLAlchemy, you should use one of the official tutorials, such as this:
https://docs.sqlalchemy.org/en/latest/core/tutorial.html -- SQLAlchemy - The Python SQL Toolkit and Object Relational Mapper http://www.sqlalchemy.org/ To post example code, please provide an MCVE: Minimal, Complete, and Verifiable Example. See http://stackoverflow.com/help/mcve for a full description. --- 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 https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.
