Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Python Data Analysis Cookbook

You're reading from   Python Data Analysis Cookbook Clean, scrape, analyze, and visualize data with the power of Python!

Arrow left icon
Product type Paperback
Published in Jul 2016
Publisher
ISBN-13 9781785282287
Length 462 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Ivan Idris Ivan Idris
Author Profile Icon Ivan Idris
Ivan Idris
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Laying the Foundation for Reproducible Data Analysis FREE CHAPTER 2. Creating Attractive Data Visualizations 3. Statistical Data Analysis and Probability 4. Dealing with Data and Numerical Issues 5. Web Mining, Databases, and Big Data 6. Signal Processing and Timeseries 7. Selecting Stocks with Financial Data Analysis 8. Text Mining and Social Network Analysis 9. Ensemble Learning and Dimensionality Reduction 10. Evaluating Classifiers, Regressors, and Clusters 11. Analyzing Images 12. Parallelism and Performance A. Glossary
B. Function Reference C. Online Resources D. Tips and Tricks for Command-Line and Miscellaneous Tools Index

Adding a table column to an existing table

If we use an object-relational mapper (ORM), such as SQLAlchemy, we map classes to tables and class attributes to table columns. Often, due to new business requirements, we need to add a table column and corresponding class attribute. We will probably need to populate the column immediately after adding it.

If we deal with a production database, then probably you do not have direct access. Luckily, we can generate SQL with Alembic, which a database administrator can review.

Getting ready

Refer to the Setting up database migration scripts recipe.

How to do it…

Alembic has its own versioning system, which requires extra tables. It also creates a versions directory under the alembic directory with generated Python code files. We need to specify the types of change necessary for migration in these files:

  1. Create a new revision, as follows:
    $ alembic revision -m "Add a column"
    
  2. Open the generated Python file (for instance, 27218d73000_add_a_column...
lock icon The rest of the chapter is locked
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Python Data Analysis Cookbook
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at ₹800/month. Cancel anytime
Modal Close icon
Modal Close icon