Professional Documents
Culture Documents
Autoloading Tables From A Database: Sqlalchemy Documentation
Autoloading Tables From A Database: Sqlalchemy Documentation
You can learn a lot more about connection strings in the SQLAlchemy documentation.
Your job in this exercise is to create an engine that connects to a local SQLite file named
census.sqlite. Then, print the names of the tables it contains using the .table_names()
method. Note that when you just want to print the table names, you do not need to use
engine.connect() after creating the engine.
In this exercise, your job is to reflect the census table available on your engine into a
variable called census. The metadata has already been loaded for you using MetaData()
and is available in the variable metadata.
Instructions
100 XP
In this exercise, you'll use a traditional SQL query. In the next exercise, you'll move to
SQLAlchemy and begin to understand its advantages. Go for it!
Instructions
100 XP
Build a SQL statement to query all the columns from census and store it in stmt.
Note that your SQL statement must be a string.
Use the .execute() and .fetchall() methods on connection and store the result
in results. Remember that .execute() comes before .fetchall() and that stmt
needs to be passed to .execute().
Print results.
Following this, we can use the metadata container to find out more details about the
reflected table such as the columns and their types. For example, table objects are stored in
the metadata.tables dictionary, so you can get the metadata of your census table with
metadata.tables['census']. This is similar to your use of the repr() function on the
census table from the previous exercise.
Instructions
100 XP
Reflect the census table as you did in the previous exercise using the Table()
function.
Print a list of column names of the census table by applying the .keys() method to
census.columns.
Print the details of the census table using the metadata.tables dictionary along
with the repr() function. To do this, first access the 'census' key of the
metadata.tables dictionary, and place this inside the provided repr() function.
e) Una variante de las anteriores que se está desarrollando son las células
fotovoltaicas hibridas que pretenden conseguir las ventajas de los
materiales orgánicos e inorgánicos tales como el menor coste y la mayor
eficiencia
La tecnología solar térmica presenta unos costes bastantes más elevados que la
fotovoltaica. Sin embargo, presenta mayores posibilidades de almacenamiento
(principalmente utilizando tecnologías de almacenamiento de vapor en recipientes
a presión o almacenamiento en sales fundidas).