Python Forum
Python Obstacles | Kapap | Wiki Scraped Content [Column Nulling]
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Obstacles | Kapap | Wiki Scraped Content [Column Nulling]
#1
Python Obstacles | Kapap | Wiki Scraped Content [Column Nulling]

I am trying to learn how to null every row in an entire MariaDB 10.4.22 Database!

I will put the solution in Python format.

This is what I have tried so far; instead of nulling current values to null value, I ended up with new inserted null rows. The ID column with AUTO_INCREMENT enabled also did not continue from entry 99 (I copied the Tables from another to create 1 for each American Independent and Free State, USA Constitutionally Guaranteed and Protected Republic.) For some reason this attempt at nulling the entire column because AK has Boroughs rather than American Counties. Started the entries at 128, then another 129 and 130 on my last when I understood what just happened.

Questions:

Does anyone know the MariaDB Syntax to actually achieve what I am trying to accomplish?

Does anyone know why my ID's did not continue at 99?

Database changed
MariaDB [Eggnest]> INSERT INTO WTPO_Dirty_Wiki_Counties_AK(american_county_name) values(NULL);
Query OK, 1 row affected (0.098 sec)

MariaDB [Eggnest]> INSERT INTO WTPO_Dirty_Wiki_Counties_AK(american_county_name) values(NULL);
Query OK, 1 row affected (0.087 sec)

MariaDB [Eggnest]> INSERT INTO WTPO_Dirty_Wiki_Counties_AK(american_county_name) values(NULL);
Query OK, 1 row affected (0.086 sec)

MariaDB [Eggnest]>
[Image: ACTUAL-1-2022-01-02-18-12-48.png]

Does anyone know the correct syntax to null value an entire column? Would ALTER be more appropriate perhaps?

Thank you everyone for this forum!

Best Regards,

Brandon
“And one of the elders saith unto me, Weep not: behold, the Lion of the tribe of Juda, the Root of David, hath prevailed to open the book,...” - Revelation 5:5 (KJV)

“And oppress not the widow, nor the fatherless, the stranger, nor the poor; and ...” - Zechariah 7:10 (KJV)

#LetHISPeopleGo

Reply
#2
I found the MariaDB CLI Command!

Source - Blog/Tutorial:

https://stackoverflow.com/questions/2746...f-a-column

MariaDB [Eggnest]> UPDATE WTPO_Dirty_Wiki_Counties_AK SET american_county_name = NULL;
Query OK, 99 rows affected (0.084 sec)
Rows matched: 102  Changed: 99  Warnings: 0

MariaDB [Eggnest]>
[Image: SOLUTION-2022-01-02-19-35-30.png]
“And one of the elders saith unto me, Weep not: behold, the Lion of the tribe of Juda, the Root of David, hath prevailed to open the book,...” - Revelation 5:5 (KJV)

“And oppress not the widow, nor the fatherless, the stranger, nor the poor; and ...” - Zechariah 7:10 (KJV)

#LetHISPeopleGo

Reply
#3
Solved!

Thank you to ndc85430 who linked me to PyMySQL on my other thread: Krav Maga: https://python-forum.io/thread-35939-pos...#pid151485

It worked great for sending the MariaDB CLI Command directly through Python! SQL Alchemy was not the best solution it proved!

I entered values into row 1, 2 and 3 as Alpha!

[Image: CURRENT-2022-01-02-19-56-50.png]
whats my screen size

Here is the working Python Script: Kapap


# Finalized on Python-Forum.io
# Disabled American Constitutional Pre-Law Student: BrandonKastning
# Date: 01/02/2021
# Script: kapap_WTPO_AK.py
# Purpose: Building Block for Python 3.9.9 + MariaDB 10.4.22
# Thread URL with Sources of Learning (Cited on Board)
# Thread URL : https://python-forum.io/thread-35958-post-151561.html
# Kapap
# DB: Eggnest
# Table: WTPO_Dirty_Wiki_Counties_AK
# Purpose: Null All Entries (Rows) within a Column using Python rather than MariaDB CLI

import pymysql.cursors

# Connect to the database
connection = pymysql.connect(host='localhost',
                             user='brandon',
                             password='password',
                             database='Eggnest',
                             cursorclass=pymysql.cursors.DictCursor)

with connection:
    with connection.cursor() as cursor:
        sql = "UPDATE WTPO_Dirty_Wiki_Counties_AK SET american_county_name = NULL;"
        cursor.execute(sql)
brandon@FireDragon:~/Python/05_Kapap$ python3 kapap_WTPO_AK.py
Solution Worked:

[Image: SOLUTION-2022-01-02-20-06-43.png]

Thank you everyone for this forum!

Best Regards,

Brandon Kastning
“And one of the elders saith unto me, Weep not: behold, the Lion of the tribe of Juda, the Root of David, hath prevailed to open the book,...” - Revelation 5:5 (KJV)

“And oppress not the widow, nor the fatherless, the stranger, nor the poor; and ...” - Zechariah 7:10 (KJV)

#LetHISPeopleGo

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Weird characters scraped samuelbachorik 3 854 Oct-29-2023, 02:36 PM
Last Post: DeaD_EyE
  Web scraper not populating .txt with scraped data BlackHeart 5 1,449 Apr-03-2023, 05:12 PM
Last Post: snippsat
  Retrieve website content using Python? Vadanane 1 1,196 Jan-16-2023, 09:55 AM
Last Post: Axel_Erfurt
Question Python Obstacles | Jeet-Kune-Do | BS4 (Tags > MariaDB) [URL/Local HTML] BrandonKastning 0 1,400 Feb-08-2022, 08:55 PM
Last Post: BrandonKastning
  Python Obstacles | Krav Maga | Wiki Scraped Content [Column Copy] BrandonKastning 4 2,160 Jan-03-2022, 06:59 AM
Last Post: BrandonKastning
Lightbulb Python Obstacles | Kung-Fu | Full File HTML Document Scrape and Store it in MariaDB BrandonKastning 5 2,817 Dec-29-2021, 02:26 AM
Last Post: BrandonKastning
  Python Obstacles | American Kenpo | Wiki Scrape URL/Table and Store it in MariaDB BrandonKastning 6 2,782 Dec-29-2021, 12:38 AM
Last Post: BrandonKastning
  Python Obstacles | Karate | HTML/Scrape Specific Tag and Store it in MariaDB BrandonKastning 8 3,090 Nov-22-2021, 01:38 AM
Last Post: BrandonKastning
  Python Web Scraping can not getting all HTML content yqqwe123 0 1,614 Aug-02-2021, 08:56 AM
Last Post: yqqwe123
  to scrape wiki-page: getting back the results - can i use pandas also apollo 2 2,602 Feb-09-2021, 03:57 PM
Last Post: apollo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020