Master SQL with Python: Lesson 12 - Maintaining Data in PostgreSQL using Upsert

  Рет қаралды 3,932

Bryan Cafferky

Bryan Cafferky

Күн бұрын

Пікірлер: 21
@lastdance903
@lastdance903 2 жыл бұрын
This is by far the most practical and elaborated free lecture I have ever seen online. Thank you Bryan, the way you presented made it really easy for beginners to understand! I am almost finishing your Master SQL with Python series and will certainly continue with your Databrick series upon completion. I have a small favor to ask though, could you please do a DW upsert video (preferably still in PostgresQL and/or Sqlite) with respect to Slowly Changing Dimension Type 2? If time is not available, would you please recommend some learning resources? I haven seen a lot of videos focusing on the fundamental DW concepts, but none like you do to actually provide practical coding examples to the audience. Best Wishes!
@BryanCafferky
@BryanCafferky 2 жыл бұрын
Thank you. And for the new video idea.
@camilotorres9835
@camilotorres9835 9 ай бұрын
You don't know how much you saved me! Thankyou very much
@BryanCafferky
@BryanCafferky 9 ай бұрын
Great!
@JimRohn-u8c
@JimRohn-u8c 2 жыл бұрын
Can I use the Upsert statement if placed in a Transaction to implement Primary and Foreign key constraints along with ON UPDATE CASCADE and ON DELETE CASCADE? In MPP databases (Snowflake, Synapse, Redshift, etc.) they do NOT enforce constraints except for NOT NULL, so I need to find a way to enforce the aforementioned constraints with SQL/Procedural SQL. In MPP Databases they only have primary & foreign keys as documentation they aren’t actually enforced. Btw I love all your videos please don’t ever stop teaching!
@granand
@granand 3 жыл бұрын
Thank you Sir. This is what I was looking for.
@rajsankar9867
@rajsankar9867 2 жыл бұрын
Bryan, Is there way to merge the data from "databricks- dataframe" to oracle over jdbc connection?
@BryanCafferky
@BryanCafferky 2 жыл бұрын
Here's the docs on using JDBC. Does not seem to support Merge. docs.microsoft.com/en-us/azure/databricks/data/data-sources/sql-databases However, if you define a Spark SQL table on top of the Oracle table using JDBC, you may be able to do something like that. Not sure. Delta tables support Merge so maybe this would trick it into letting you do that. I did a video on this awhile back: kzbin.info/www/bejne/kJLInIOweNSMoNU This blog uses a different approach. medium.com/@thomaspt748/how-to-upsert-data-into-relational-database-using-spark-7d2d92e05bb9 A bit of work but looks possible.
@rajsankar9867
@rajsankar9867 2 жыл бұрын
@@BryanCafferky Thank you for your noble service.
@stu8924
@stu8924 3 жыл бұрын
Hi Brian, Thank you for producing such a great array of videos. In regards to the video above, Is there a way in which I can use the code demonstrated above to include a type 2 SCD model? I would like to be able to keep all changes to a record over time. For example Salary increases and alike. Best Wishes, Stuart
@BryanCafferky
@BryanCafferky 3 жыл бұрын
The code demonstrated shows how to execute SQL data maintenance statements so yes, you can use it as a shell to do the more complex SCD Type 2 data maintenance. However, Salary is normally a Fact, not a Dimension, so you may need to re-think how you intend to do reporting on it. If you need to implement an SCD Type 2 dimension, this stackoverflow blog is a place to start. stackoverflow.com/questions/56623502/designing-a-slowly-changing-dimension-type-2-script-with-postgresql
@stu8924
@stu8924 3 жыл бұрын
​@@BryanCafferky Thank you Bryan.
@AlanThompson-j2f
@AlanThompson-j2f 10 ай бұрын
Hi Brian I've followed all of your Python and Master SQL with python lessons so far - truly a source of GOLD. I'm stuck though on this lesson 12 when trying to use conn.execute - at the first hurdle: conn.execute('DROP TABLE IF EXISTS youtube_customer') No matter what I try, I always get AttributeError: 'Engine' object has no attribute 'execute'. Have you come across this error - assuming it is that sqlalchemy has moved on, and doesn't except execute now, but I'm stuck on what the alternative is. Any help - supremely thankful
@kosprov69
@kosprov69 3 жыл бұрын
Is there an easier way to update all the columns together instead of having to pass their names one by one as column_name = excluded.{column_name}. Thanks for the great vid
@BryanCafferky
@BryanCafferky 3 жыл бұрын
Technically no as far as I can determine. If you delete the row and re-insert it, that would work but that's a lot of overhead. See this StackOverflow blog stackoverflow.com/questions/29926765/how-to-update-all-columns-of-a-record-without-having-to-list-every-column
@kosprov69
@kosprov69 3 жыл бұрын
@@BryanCafferky Thanks for the quick reply. Appreciate the effort!
@granand
@granand 3 жыл бұрын
I will soon start to extract, create objects in SQL using PL SQL, oracle system. I may get access to Dbeaver editor but please I use python & jupyter
@BryanCafferky
@BryanCafferky 3 жыл бұрын
Are you asking for a video that covers this using Oracle?
@granand
@granand 3 жыл бұрын
@@BryanCafferky I follow your videos so take opportunity to say big thanks & opportunity to learn python & SQL. Yes Sir, soon I would be asked to fetch reports, analyse, update oracle databases & I work for govt & won't install anything. I would be keen to do data analysis, tables update using Python. Your help is appreciated either here or via udemy etc.
@ravitutika1204
@ravitutika1204 3 жыл бұрын
Thank you
@miguelmonteiro4456
@miguelmonteiro4456 2 жыл бұрын
Ver good..
Master Using SQL with Python: Lesson 7.2 - Using the SQLite Upsert
20:59
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,2 МЛН
“Don’t stop the chances.”
00:44
ISSEI / いっせい
Рет қаралды 61 МЛН
Introduction to Scaling Analytics Using DuckDB with Python
29:33
Bryan Cafferky
Рет қаралды 4,4 М.
This Is Why Python Data Classes Are Awesome
22:19
ArjanCodes
Рет қаралды 818 М.
Master Using SQL with Python:  Lesson 8 - Introducing PostgreSQL
59:47
Bryan Cafferky
Рет қаралды 3,9 М.
Solving one of PostgreSQL's biggest weaknesses.
17:12
Dreams of Code
Рет қаралды 219 М.
Learn Database Normalization - 1NF, 2NF, 3NF, 4NF, 5NF
28:34
Decomplexify
Рет қаралды 2,1 МЛН
SQLite Databases With Python - Full Course
1:29:37
freeCodeCamp.org
Рет қаралды 692 М.
Database Indexing Explained (with PostgreSQL)
18:19
Hussein Nasser
Рет қаралды 322 М.