inital commit
This commit is contained in:
10
README.MD
Normal file
10
README.MD
Normal file
@@ -0,0 +1,10 @@
|
||||
# Header
|
||||
|
||||
## Usage
|
||||
|
||||
start the db with docker-compose.yml
|
||||
create the tables and fill them with mock-data using mockdata.sql
|
||||
run the script segfault_python.py and see how everything is fine.
|
||||
change the zero-padding of the uid column with change_zfill.sql
|
||||
run the script segfault_python.py and watch the world burn.
|
||||
|
||||
1
change_zfill.sql
Normal file
1
change_zfill.sql
Normal file
@@ -0,0 +1 @@
|
||||
ALTER TABLE `test_data`.`accounts` CHANGE COLUMN `uid` `uid` INT(10) ZEROFILL
|
||||
21
docker-compose.yml
Normal file
21
docker-compose.yml
Normal file
@@ -0,0 +1,21 @@
|
||||
# Use root/example as user/password credentials
|
||||
version: '3.1'
|
||||
|
||||
services:
|
||||
|
||||
db:
|
||||
image: mariadb
|
||||
restart: always
|
||||
volumes:
|
||||
- ./mysql_data:/var/lib/mysql
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: test
|
||||
ports:
|
||||
- 3306:3306
|
||||
|
||||
adminer:
|
||||
image: adminer
|
||||
restart: always
|
||||
ports:
|
||||
- 8080:8080
|
||||
|
||||
1009
mockdata.sql
Normal file
1009
mockdata.sql
Normal file
File diff suppressed because it is too large
Load Diff
31
segfault_python.py
Normal file
31
segfault_python.py
Normal file
@@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Module Imports
|
||||
import mariadb
|
||||
import sys
|
||||
|
||||
# Connect to MariaDB Platform
|
||||
try:
|
||||
conn = mariadb.connect(
|
||||
user="root",
|
||||
password="test",
|
||||
host="127.0.0.1",
|
||||
port=3306,
|
||||
database="test_data"
|
||||
|
||||
)
|
||||
except mariadb.Error as e:
|
||||
print(f"Error connecting to MariaDB Platform: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
# Get Cursor
|
||||
cur = conn.cursor()
|
||||
|
||||
acc_id = int(input("Input: "))
|
||||
|
||||
cur.execute(f"SELECT first_name,last_name,balance,uid FROM `accounts` WHERE `uid` LIKE \"{acc_id}\"")
|
||||
|
||||
for (first_name, last_name, balance, uid) in cur:
|
||||
print(str(uid).zfill(10), first_name, last_name, balance)
|
||||
|
||||
conn.close()
|
||||
Reference in New Issue
Block a user