current
All checks were successful
test / build-docs (push) Successful in -19s

This commit is contained in:
2025-07-10 21:03:06 +02:00
parent 11a0aa2d89
commit a692ac8b05
19 changed files with 3931 additions and 28 deletions

View File

@@ -1,5 +1,7 @@
#! /usr/bin/env python3.12
import subprocess, os
#! /usr/bin/env python3.13
import os
import subprocess
def import_ssh_keys_to_agent(privat_key=str):
try:
@@ -9,7 +11,8 @@ def import_ssh_keys_to_agent(privat_key = str):
text=False,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
timeout=10,)
timeout=10,
)
except subprocess.TimeoutExpired:
print("\n", "Timeout, No Import :", privat_key)
@@ -30,7 +33,8 @@ def check_key_exist(ssh_pub=str):
shell=False,
text=False,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,)
stderr=subprocess.PIPE,
)
list_agent_pubs = str(run_check_key.stdout, encoding="utf-8").splitlines()
read_input_pub = open(ssh_pub)
@@ -43,7 +47,6 @@ def check_key_exist(ssh_pub=str):
return False
if __name__ == "__main__":
ssh_keys = [
"/home/jonnybravo/.ssh/ansible-test",

32
create_ps/create_ps.py Executable file
View File

@@ -0,0 +1,32 @@
#! /usr/bin/env python
import string
import secrets
def create_password(long=int(10), sonder="!#$%&()*+-/:;<=>?@[]_{|}"):
print("Sonderzeichen:", sonder)
alle = string.ascii_letters + string.digits + sonder
while True:
tx = ""
anz = [0, 0, 0, 0]
for i in range(long):
zeichen = secrets.choice(alle)
tx += zeichen
if zeichen in string.ascii_lowercase:
anz[0] += 1
elif zeichen in string.ascii_uppercase:
anz[1] += 1
elif zeichen in string.digits:
anz[2] += 1
else:
anz[3] += 1
# print("Anzahl:", anz)
if 0 not in anz:
break
return tx
if __name__ == "__main__":
print(create_password(long=20))

View File

@@ -0,0 +1,7 @@
Folgende Punkte
- erstellen eine SQlite DB
- Die DB soll folgende Tabellen haben Genre, MyList,
- Die Anzeige soll über Flask angezeigt werden
Weitere Schritte folgen !!!

View File

@@ -0,0 +1,69 @@
import DBcm
def create_movie_database(db_name="movie_db.db"):
create_my_list = """
create table if not exists movie_list (
id integer not null primary key autoincrement,
titel varchar(64) not null,
genre_id integer not null,
regie_id integer not null
)
"""
create_genre = """
create table if not exists genre (
id integer not null primary key autoincrement,
name varchar(64) not null
)
"""
create_regie = """
create table if not exists regie (
id integer not null primary key autoincrement,
surname varchar(64) not null,
lastname varchr(64) not null
)
"""
create_medium = """
create table if not exists medium (
id integer not null primary key autoincrement,
medium varchar(64) not null
)
"""
with DBcm.UseDatabase(db_name) as db:
db.execute(create_my_list)
db.execute(create_genre)
db.execute(create_regie)
db.execute(create_medium)
def all_genres(db_name="movie_db.db"):
ALL_GENRE = "SELECT * from genre"
with DBcm.UseDatabase(db_name) as db:
db.execute(ALL_GENRE)
all_genre = [i[1] for i in db.fetchall()]
return all_genre
def search_genre_id(db_name="movie_db.db", genre_name=str):
GENRE_QUERY = """
select id from genre
where name = ?
"""
try:
with DBcm.UseDatabase(db_name) as db:
db.execute(GENRE_QUERY, (genre_name,))
genre_id = db.fetchone()[0]
return int(genre_id)
except:
return int(0)
if __name__ == "__main__":
create_movie_database()
print(all_genres())
print(search_genre_id(genre_name="war"))

View File

@@ -0,0 +1,534 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "5263a987-da36-46d7-a2e7-d0658cda09c1",
"metadata": {},
"outputs": [],
"source": [
"import DBcm"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "3f6b0763-4106-4bfa-9aef-7afbd180c6d4",
"metadata": {},
"outputs": [],
"source": [
"db_name = \"movie_db.db\"\n",
"\n",
"create_my_list = \"\"\"\n",
" create table if not exists movie_list (\n",
" id integer not null primary key autoincrement,\n",
" titel varchar(64) not null,\n",
" genre_id integer not null,\n",
" regie_id integer not null\n",
" \n",
" )\n",
"\n",
"\"\"\"\n",
"\n",
"create_genre = \"\"\"\n",
" create table if not exists genre (\n",
" id integer not null primary key autoincrement,\n",
" name varchar(64) not null\n",
" )\n",
"\"\"\"\n",
"\n",
"create_regie = \"\"\"\n",
" create table if not exists regie (\n",
" id integer not null primary key autoincrement,\n",
" surname varchar(64) not null,\n",
" lastname varchr(64) not null\n",
" )\n",
"\"\"\"\n",
"\n",
"\n",
"with DBcm.UseDatabase(db_name) as db: \n",
" db.execute(create_my_list)\n",
" db.execute(create_genre)\n",
" db.execute(create_regie)\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "376ef812-97b5-45ba-8ef1-eb8d7829494a",
"metadata": {},
"outputs": [],
"source": [
"# ADDed Genre values\n",
"\n",
"ADD_GENRE_VALUE = \"\"\"\n",
" INSERT INTO genre(name)\n",
" SELECT ?\n",
" WHERE NOT EXISTS (SELECT 1 FROM genre WHERE name = ?);\n",
" \"\"\"\n",
"\n",
"with open(\"genre_list\", \"r\") as fs: \n",
" for genre_value in fs.readlines():\n",
" with DBcm.UseDatabase(db_name) as db:\n",
" db.execute(ADD_GENRE_VALUE, (genre_value.strip(), genre_value.strip()))\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "63b16a41-88bf-4832-a26c-09180832f597",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['action', 'adventure', 'animation', 'biography', 'comedy', 'crime', 'cult movie', 'disney', 'documentary', 'drama', 'erotic', 'family', 'fantasy', 'film-noir', 'gangster', 'gay and lesbian', 'history', 'horror', 'military', 'music', 'musical', 'mystery', 'nature', 'neo-noir', 'period', 'pixar', 'road movie', 'romance', 'sci-fi', 'short', 'spy', 'super hero', 'thriller', 'visually stunning', 'war', 'western']\n"
]
}
],
"source": [
"def all_genres():\n",
" ALL_GENRE = \"\"\"\n",
" SELECT * from genre \n",
" \"\"\" \n",
" with DBcm.UseDatabase(db_name) as db:\n",
" db.execute(ALL_GENRE)\n",
" all_genre = [i[1] for i in db.fetchall()]\n",
" \n",
" return all_genre\n",
"\n",
"print(all_genres())\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "89b20b5f-34aa-4490-a4c0-c186c9fa30bd",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n",
"36\n"
]
}
],
"source": [
"def search_genre_id(genre_name):\n",
" GENRE_QUERY = \"\"\"\n",
" select id from genre\n",
" where name = ?\n",
" \"\"\"\n",
" try:\n",
" with DBcm.UseDatabase(db_name) as db:\n",
" db.execute(GENRE_QUERY,(genre_name,))\n",
" genre_id = db.fetchone()[0]\n",
" return int(genre_id)\n",
" except:\n",
" return int(0)\n",
"\n",
"\n",
"def search_medium_id(genre_name):\n",
" GENRE_QUERY = \"\"\"\n",
" select id from genre\n",
" where medium = ?\n",
" \"\"\"\n",
" try:\n",
" with DBcm.UseDatabase(db_name) as db:\n",
" db.execute(GENRE_QUERY,(genre_name,))\n",
" genre_id = db.fetchone()[0]\n",
" return int(genre_id)\n",
" except:\n",
" return int(0)\n",
"\n",
"print(search_genre_id(genre_name=\"action\"))\n",
"print(search_genre_id(genre_name=\"western\"))"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "c70d91a5-7855-465d-a4a6-daebc065ee37",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0-John-Smith\n",
"1-James-Johnson\n",
"2-William-Williams\n",
"3-Michael-Brown\n",
"4-David-Davis\n",
"5-Richard-Miller\n",
"6-Joseph-Wilson\n",
"7-Charles-Moore\n",
"8-Thomas-Taylor\n",
"9-Daniel-Anderson\n",
"10-Paul-Thomas\n",
"11-Mark-Jackson\n",
"12-Donna-White\n",
"13-Michelle-Harris\n",
"14-Laura-Martin\n",
"15-Sara-Thompson\n",
"16-Ana-Garcia\n",
"17-Carlos-Rodriguez\n",
"18-Maria-Martinez\n",
"19-Jose-Hernandez\n",
"20-Luis-Lopez\n",
"21-Rosa-Gonzalez\n",
"22-Pedro-Perez\n",
"23-Miguel-Sanchez\n",
"24-Juan-Ramirez\n",
"25-Ana-Flores\n",
"26-Isabella-Cruz\n",
"27-Victor-Rivera\n",
"28-Kevin-Lee\n",
"29-Brian-Walker\n",
"30-Emily-Hall\n",
"31-Ryan-Allen\n",
"32-Aaron-Young\n",
"33-Jeffrey-King\n",
"34-Joshua-Wright\n",
"35-Brandon-Scott\n",
"36-Frank-Turner\n",
"37-Gregory-Carter\n",
"38-Samuel-Phillips\n",
"39-Chris-Evans\n",
"40-Anthony-Collins\n",
"41-Eric-Stewart\n",
"42-Frank-Snyder\n",
"43-Thomas-Baker\n",
"44-Jeremy-Nelson\n",
"45-Steven-Roberts\n",
"46-Edward-Campbell\n",
"47-Ryan-Miller\n",
"48-Jacob-Davis\n",
"49-David-Garcia\n",
"50-Sophia-Rodriguez\n",
"51-Emma-Martinez\n",
"52-Noah-Hernandez\n",
"53-Ava-Lopez\n",
"54-Ethan-Gonzalez\n",
"55-Mia-Perez\n",
"56-William-Sanchez\n",
"57-James-Ramirez\n",
"58-Olivia-Flores\n",
"59-Lucas-Cruz\n",
"60-Isabella-Rivera\n",
"61-David-Lee\n",
"62-Sophie-Walker\n",
"63-Matthew-Hall\n",
"64-Emma-Allen\n",
"65-Ryan-Young\n",
"66-Ava-King\n",
"67-Ethan-Wright\n",
"68-Mia-Scott\n",
"69-William-Turner\n",
"70-James-Carter\n",
"71-Olivia-Phillips\n",
"72-Lucas-Evans\n",
"73-Sophie-Collins\n",
"74-Noah-Stewart\n",
"75-Ava-Snyder\n",
"76-Ethan-Baker\n",
"77-Mia-Nelson\n",
"78-Noah-Roberts\n",
"79-Emma-Campbell\n",
"80-William-Miller\n",
"81-James-Davis\n",
"82-Olivia-Garcia\n",
"83-Lucas-Rodriguez\n",
"84-Sophie-Martinez\n",
"85-Noah-Hernandez\n",
"86-Ava-Lopez\n",
"87-Ethan-Gonzalez\n",
"88-Mia-Perez\n",
"89-William-Sanchez\n",
"90-James-Ramirez\n",
"91-Olivia-Flores\n",
"92-Lucas-Cruz\n",
"93-Isabella-Rivera\n",
"94-David-Lee\n",
"95-Sophie-Walker\n",
"96-Matthew-Hall\n",
"97-Emma-Allen\n",
"98-Ryan-Young\n",
"99-Ava-King\n",
"100-Ethan-Wright\n",
"101-Mia-Scott\n",
"102-William-Turner\n",
"103-James-Carter\n",
"104-Olivia-Phillips\n",
"105-Lucas-Evans\n",
"106-Sophie-Collins\n",
"107-Noah-Stewart\n",
"108-Ava-Snyder\n",
"109-Ethan-Baker\n",
"110-Mia-Nelson\n",
"111-Noah-Roberts\n",
"112-Emma-Campbell\n",
"113-William-Miller\n",
"114-James-Davis\n",
"115-Olivia-Garcia\n",
"116-Lucas-Rodriguez\n",
"117-Sophie-Martinez\n",
"118-Noah-Hernandez\n",
"119-Ava-Lopez\n",
"120-Ethan-Gonzalez\n",
"121-Mia-Perez\n",
"122-William-Sanchez\n",
"123-James-Ramirez\n",
"124-Olivia-Flores\n",
"125-Lucas-Cruz\n",
"126-Isabella-Rivera\n",
"127-David-Lee\n",
"128-Sophie-Walker\n",
"129-Matthew-Hall\n",
"130-Emma-Allen\n",
"131-Ryan-Young\n",
"132-Ava-King\n",
"133-Ethan-Wright\n",
"134-Mia-Scott\n",
"135-William-Turner\n",
"136-James-Carter\n",
"137-Olivia-Phillips\n",
"138-Lucas-Evans\n",
"139-Sophie-Collins\n",
"140-Noah-Stewart\n",
"141-Ava-Snyder\n",
"142-Ethan-Baker\n",
"143-Mia-Nelson\n",
"144-Noah-Roberts\n",
"145-Emma-Campbell\n",
"146-William-Miller\n",
"147-James-Davis\n",
"148-Olivia-Garcia\n",
"149-Lucas-Rodriguez\n",
"150-Sophie-Martinez\n",
"151-Noah-Hernandez\n",
"152-Ava-Lopez\n",
"153-Ethan-Gonzalez\n",
"154-Mia-Perez\n",
"155-William-Sanchez\n",
"156-James-Ramirez\n",
"157-Olivia-Flores\n",
"158-Lucas-Cruz\n",
"159-Isabella-Rivera\n",
"160-David-Lee\n",
"161-Sophie-Walker\n",
"162-Matthew-Hall\n",
"163-Emma-Allen\n",
"164-Ryan-Young\n",
"165-Ava-King\n",
"166-Ethan-Wright\n",
"167-Mia-Scott\n",
"168-William-Turner\n",
"169-James-Carter\n",
"170-Olivia-Phillips\n",
"171-Lucas-Evans\n",
"172-Sophie-Collins\n",
"173-Noah-Stewart\n",
"174-Ava-Snyder\n",
"175-Ethan-Baker\n",
"176-Mia-Nelson\n",
"177-Noah-Roberts\n",
"178-Emma-Campbell\n",
"179-William-Miller\n",
"180-James-Davis\n",
"181-Olivia-Garcia\n",
"182-Lucas-Rodriguez\n",
"183-Sophie-Martinez\n",
"184-Noah-Hernandez\n",
"185-Ava-Lopez\n",
"186-Ethan-Gonzalez\n",
"187-Mia-Perez\n",
"188-William-Sanchez\n",
"189-James-Ramirez\n",
"190-Olivia-Flores\n",
"191-Lucas-Cruz\n",
"192-Isabella-Rivera\n",
"193-David-Lee\n",
"194-Sophie-Walker\n",
"195-Matthew-Hall\n",
"196-Emma-Allen\n",
"197-Ryan-Young\n",
"198-Ava-King\n",
"199-Ethan-Wright\n",
"200-Mia-Scott\n",
"201-William-Turner\n",
"202-James-Carter\n",
"203-Olivia-Phillips\n",
"204-Lucas-Evans\n",
"205-Sophie-Collins\n",
"206-Noah-Stewart\n",
"207-Ava-Snyder\n",
"208-Ethan-Baker\n",
"209-Mia-Nelson\n",
"210-Noah-Roberts\n",
"211-Emma-Campbell\n",
"212-William-Miller\n",
"213-James-Davis\n",
"214-Olivia-Garcia\n",
"215-Lucas-Rodriguez\n",
"216-Sophie-Martinez\n",
"217-Noah-Hernandez\n",
"218-Ava-Lopez\n",
"219-Ethan-Gonzalez\n",
"220-Mia-Perez\n",
"221-William-Sanchez\n",
"222-James-Ramirez\n",
"223-Olivia-Flores\n",
"224-Lucas-Cruz\n",
"225-Isabella-Rivera\n",
"226-David-Lee\n",
"227-Sophie-Walker\n",
"228-Matthew-Hall\n",
"229-Emma-Allen\n",
"230-Ryan-Young\n",
"231-Ava-King\n",
"232-Ethan-Wright\n",
"233-Mia-Scott\n",
"234-William-Turner\n",
"235-James-Carter\n",
"236-Olivia-Phillips\n",
"237-Lucas-Evans\n",
"238-Sophie-Collins\n",
"239-Noah-Stewart\n",
"240-Ava-Snyder\n",
"241-Ethan-Baker\n",
"242-Mia-Nelson\n",
"243-Noah-Roberts\n",
"244-Emma-Campbell\n",
"245-William-Miller\n",
"246-James-Davis\n",
"247-Olivia-Garcia\n",
"248-Lucas-Rodriguez\n",
"249-Sophie-Martinez\n",
"250-Noah-Hernandez\n",
"251-Ava-Lopez\n",
"252-Ethan-Gonzalez\n",
"253-Mia-Perez\n",
"254-William-Sanchez\n",
"255-James-Ramirez\n",
"256-Olivia-Flores\n",
"257-Lucas-Cruz\n",
"258-Isabella-Rivera\n",
"259-David-Lee\n",
"260-Sophie-Walker\n",
"261-Matthew-Hall\n",
"262-Emma-Allen\n",
"263-Ryan-Young\n",
"264-Ava-King\n",
"265-Ethan-Wright\n",
"266-Mia-Scott\n",
"267-William-Turner\n",
"268-James-Carter\n",
"269-Olivia-Phillips\n",
"270-Lucas-Evans\n",
"271-Sophie-Collins\n",
"272-Noah-Stewart\n",
"273-Ava-Snyder\n",
"274-Ethan-Baker\n",
"275-Mia-Nelson\n",
"276-Noah-Roberts\n",
"277-Emma-Campbell\n",
"278-William-Miller\n",
"279-James-Davis\n",
"280-Olivia-Garcia\n",
"281-Lucas-Rodriguez\n",
"282-Sophie-Martinez\n",
"283-Noah-Hernandez\n",
"284-Ava-Lopez\n",
"285-Ethan-Gonzalez\n",
"286-Mia-Perez\n",
"287-William-Sanchez\n",
"288-James-Ramirez\n",
"289-Olivia-Flores\n",
"290-Lucas-Cruz\n",
"291-Isabella-Rivera\n",
"292-David-Lee\n",
"293-Sophie-Walker\n",
"294-Matthew-Hall\n",
"295-Emma-Allen\n",
"296-Ryan-Young\n",
"297-Ava-King\n",
"298-Ethan-Wright\n",
"299-Mia-Scott\n",
"300-William-Turner\n",
"301-James-Carter\n",
"302-Olivia-Phillips\n",
"303-Lucas-Evans\n",
"304-Sophie-Collins\n",
"305-Noah-Stewart\n",
"306-Ava-Snyder\n",
"307-Ethan-Baker\n",
"308-Mia-Nelson\n",
"309-Noah-Roberts\n",
"310-Emma-Campbell\n",
"311-William-Miller\n",
"312-James-Davis\n",
"313-Olivia-Garcia\n",
"314-Lucas-Rodriguez\n",
"315-Sophie-Martinez\n",
"316-Noah-Hernandez\n",
"317-Ava-Lopez\n",
"318-Ethan-Gonzalez\n",
"319-Mia-Perez\n",
"320-William-Sanchez\n",
"321-James-Ramirez\n",
"322-Olivia-Flores\n",
"323-Lucas-Cruz\n",
"324-Isabella-Rivera\n",
"325-David-Lee\n",
"326-Sophie-Walker\n"
]
}
],
"source": [
"import pandas as pd\n",
"usecols = [\"Name\", \"Vorname\"]\n",
"air = pd.read_csv(\"regie_name.csv\", usecols=usecols)\n",
"\n",
"for count, (i, b) in enumerate(zip(air[\"Name\"], air[\"Vorname\"])):\n",
" print(count, b, i, sep=\"-\")\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ee4b5dee-6b41-49eb-8d75-9db50d20fdef",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

7
movie-db/README.md Normal file
View File

@@ -0,0 +1,7 @@
Folgende Punkte
- erstellen eine SQlite DB
- Die DB soll folgende Tabellen haben Genre, MyList,
- Die Anzeige soll über Flask angezeigt werden
Weitere Schritte folgen !!!

Binary file not shown.

36
movie-db/genre_list Normal file
View File

@@ -0,0 +1,36 @@
action
adventure
animation
biography
comedy
crime
cult movie
disney
documentary
drama
erotic
family
fantasy
film-noir
gangster
gay and lesbian
history
horror
military
music
musical
mystery
nature
neo-noir
period
pixar
road movie
romance
sci-fi
short
spy
super hero
thriller
visually stunning
war
western

58
movie-db/main.py Normal file
View File

@@ -0,0 +1,58 @@
import flask
import moviedb_func
app = flask.Flask(__name__)
app.secret_key = "Start1234!"
@app.get("/add_movie")
def add_movie():
return flask.render_template(
"add_movie.html",
sitename="Meine Movieliste !!!",
url="output",
select_movie="add_movie",
select_genre="add_genre",
select_medium="add_medium",
select_regie="add_regie",
data=moviedb_func.all_select(),
data_medium=moviedb_func.all_select(what_select="medium"),
data_regie=moviedb_func.all_select(what_select="regie"),
)
@app.post("/output")
def csv_output():
select_add_movie = flask.request.form["add_movie"]
select_genre = flask.request.form["add_genre"]
select_genre_id = moviedb_func.search_id(
search_name=flask.request.form["add_genre"])
select_medium = flask.request.form["add_medium"]
select_medium_id = moviedb_func.search_id(
search_name=flask.request.form["add_medium"], select_from="medium", select_where="medium")
select_regie = flask.request.form["add_regie"]
select_regie_id = moviedb_func.search_id(
search_name=flask.request.form["add_regie"], select_from="regie", select_where="regie")
moviedb_func.add_movie_to_list(movie_name=select_add_movie, regie_id=select_regie_id,
medium_id=select_medium_id, genre_id=select_genre_id)
return flask.render_template(
"output.html",
sitename="Meine Movieliste !!!",
add_movie=select_add_movie,
add_genre=select_genre,
add_medium=select_medium,
add_regie=select_regie,
add_genre_id=select_genre_id,
add_medium_id=select_medium_id,
add_regie_id=select_regie_id
# data=modify_csv.read_csv_file(),
# sum_all=modify_csv.sum_all(),
)
if __name__ == "__main__":
app.run(port=5082, host="0.0.0.0", debug=True)

BIN
movie-db/movie_db.db Normal file

Binary file not shown.

174
movie-db/moviedb_func.py Normal file
View File

@@ -0,0 +1,174 @@
import DBcm
from mariadb import ProgrammingError
import pandas as pd
import sqlite3
def create_movie_database(db_name="movie_db.db"):
create_my_list = """
create table if not exists movie_list (
id integer not null primary key autoincrement,
titel varchar(64) not null,
genre_id integer not null,
regie_id integer not null,
medium_id integer not null
)
"""
create_genre = """
create table if not exists genre (
id integer not null primary key autoincrement,
name varchar(64) not null
)
"""
create_regie = """
create table if not exists regie (
id integer not null primary key autoincrement,
surname varchar(64) not null,
lastname varchar(64) not null
)
"""
create_medium = """
create table if not exists medium (
id integer not null primary key autoincrement,
medium varchar(64) not null
)
"""
ADD_GENRE_VALUE = """
INSERT INTO genre(name)
SELECT ?
WHERE NOT EXISTS (SELECT 1 FROM genre WHERE name = ?);
"""
ADD_MEDIUM_VALUE = """
INSERT INTO medium(medium)
SELECT ?
WHERE NOT EXISTS (SELECT 1 FROM medium WHERE medium = ?);
"""
ADD_REGIE_VALUE = """
INSERT INTO regie (surname, lastname )
SELECT ?, ?
WHERE NOT EXISTS
(SELECT surname, lastname
FROM regie
WHERE surname = ? AND lastname = ?);
"""
with DBcm.UseDatabase(db_name) as db:
db.execute(create_my_list)
db.execute(create_genre)
db.execute(create_regie)
db.execute(create_medium)
with open("genre_list", "r") as fs:
for genre_value in fs.readlines():
with DBcm.UseDatabase(db_name) as db:
db.execute(ADD_GENRE_VALUE,
(genre_value.strip(), genre_value.strip()))
usecols = ["Name", "Vorname"]
air = pd.read_csv("regie_name.csv", usecols=usecols)
for count, (reg_name, reg_vorname) in enumerate(zip(air["Name"], air["Vorname"])):
# print(count, reg_vorname, reg_name)
with DBcm.UseDatabase(db_name) as db:
db.execute(ADD_REGIE_VALUE, (reg_vorname,
reg_name, reg_vorname, reg_name))
LISTE_MEDIUM = ["BlueRay", "DVD", "Datei",
"BlueRay Steelbook", "DVD Steelbook"]
with DBcm.UseDatabase(db_name) as db:
for MEDIUM in LISTE_MEDIUM:
db.execute(ADD_MEDIUM_VALUE, (MEDIUM, MEDIUM))
def all_select(db_name="movie_db.db", what_select="genre"):
ALL_SELECT = "SELECT * from " + what_select
if what_select == "genre" or what_select == "medium":
with DBcm.UseDatabase(db_name) as db:
db.execute(ALL_SELECT)
all_value = [i[1] for i in db.fetchall()]
return all_value
elif what_select == 'regie':
all_value = []
with DBcm.UseDatabase(db_name) as db:
db.execute(ALL_SELECT)
for i in db.fetchall():
all_value.append(i[1] + " " + i[2])
return all_value
else:
return "Wrong Value !!!"
def search_id(db_name="movie_db.db", search_name=str, select_from="genre", select_where="name"):
if select_from == "regie":
split_search = search_name.split(" ")
GENRE_QUERY = f"""select id from {select_from}
where surname = ? and lastname = ?"""
with DBcm.UseDatabase(db_name) as db:
db.execute(GENRE_QUERY, (split_search[0], split_search[1],))
regie_id = db.fetchone()[0]
return int(regie_id)
else:
try:
GENRE_QUERY = f"""select id from {select_from}
where {select_where} = ?"""
with DBcm.UseDatabase(db_name) as db:
db.execute(GENRE_QUERY, (search_name,))
genre_id = db.fetchone()[0]
return int(genre_id)
except:
return int(0)
def add_movie_to_list(db_name="movie_db.db", movie_name=str, genre_id=int, regie_id=int, medium_id=int):
SQL_PARAM = f"""
INSERT INTO movie_list (titel, genre_id, regie_id, medium_id )
SELECT ?, ?, ?, ?
WHERE NOT EXISTS
(SELECT titel FROM movie_list WHERE titel = ?);
"""
try:
with DBcm.UseDatabase(db_name) as db:
db.execute(SQL_PARAM, (movie_name.lower(), genre_id,
regie_id, medium_id, movie_name.lower(),))
except ProgrammingError:
raise ProgrammingError("Konnte nicht in die DB schreiben")
return True
def show_movie_list(db_name="movie_db.db"):
SQL_PARAM = f"""SELECT
movie_list.id,
titel,
genre.name AS genre,
regie.surname as regie_surname,
regie.lastname as regie_lastname,
medium.medium
FROM movie_list
INNER JOIN genre ON movie_list.genre_id=genre.id
INNER JOIN regie ON movie_list.regie_id=regie.id
INNER JOIN medium ON movie_list.medium_id=medium.id
;
"""
db = sqlite3.connect(db_name)
SELCET_VALUE = pd.read_sql(SQL_PARAM, db)
return_list_dict = []
for id, titel, genre, regie_surname, regie_lastname in zip(SELCET_VALUE["id"], SELCET_VALUE["titel"], SELCET_VALUE["genre"], SELCET_VALUE["regie_surname"], SELCET_VALUE["regie_lastname"]):
return_list_dict.append(
{"id": id, "titel": titel, "genre": genre, "regie": regie_surname + " " + regie_lastname})
return return_list_dict
if __name__ == "__main__":
create_movie_database()
# print(all_select())
# id_genre = search_id(
# search_name="DVD", select_from="medium", select_where="medium")
add_movie_to_list(movie_name="Schlumpfland",
genre_id=1, regie_id=1, medium_id=1)
print(show_movie_list())

329
movie-db/regie_name.csv Normal file
View File

@@ -0,0 +1,329 @@
Name,Vorname
Rodriguez,Robert
Smith,John
Johnson,James
Williams,William
Brown,Michael
Davis,David
Miller,Richard
Wilson,Joseph
Moore,Charles
Taylor,Thomas
Anderson,Daniel
Thomas,Paul
Jackson,Mark
White,Donna
Harris,Michelle
Martin,Laura
Thompson,Sara
Garcia,Ana
Rodriguez,Carlos
Martinez,Maria
Hernandez,Jose
Lopez,Luis
Gonzalez,Rosa
Perez,Pedro
Sanchez,Miguel
Ramirez,Juan
Flores,Ana
Cruz,Isabella
Rivera,Victor
Lee,Kevin
Walker,Brian
Hall,Emily
Allen,Ryan
Young,Aaron
King,Jeffrey
Wright,Joshua
Scott,Brandon
Turner,Frank
Carter,Gregory
Phillips,Samuel
Evans,Chris
Collins,Anthony
Stewart,Eric
Snyder,Frank
Baker,Thomas
Nelson,Jeremy
Roberts,Steven
Campbell,Edward
Miller,Ryan
Davis,Jacob
Garcia,David
Rodriguez,Sophia
Martinez,Emma
Hernandez,Noah
Lopez,Ava
Gonzalez,Ethan
Perez,Mia
Sanchez,William
Ramirez,James
Flores,Olivia
Cruz,Lucas
Rivera,Isabella
Lee,David
Walker,Sophie
Hall,Matthew
Allen,Emma
Young,Ryan
King,Ava
Wright,Ethan
Scott,Mia
Turner,William
Carter,James
Phillips,Olivia
Evans,Lucas
Collins,Sophie
Stewart,Noah
Snyder,Ava
Baker,Ethan
Nelson,Mia
Roberts,Noah
Campbell,Emma
Miller,William
Davis,James
Garcia,Olivia
Rodriguez,Lucas
Martinez,Sophie
Hernandez,Noah
Lopez,Ava
Gonzalez,Ethan
Perez,Mia
Sanchez,William
Ramirez,James
Flores,Olivia
Cruz,Lucas
Rivera,Isabella
Lee,David
Walker,Sophie
Hall,Matthew
Allen,Emma
Young,Ryan
King,Ava
Wright,Ethan
Scott,Mia
Turner,William
Carter,James
Phillips,Olivia
Evans,Lucas
Collins,Sophie
Stewart,Noah
Snyder,Ava
Baker,Ethan
Nelson,Mia
Roberts,Noah
Campbell,Emma
Miller,William
Davis,James
Garcia,Olivia
Rodriguez,Lucas
Martinez,Sophie
Hernandez,Noah
Lopez,Ava
Gonzalez,Ethan
Perez,Mia
Sanchez,William
Ramirez,James
Flores,Olivia
Cruz,Lucas
Rivera,Isabella
Lee,David
Walker,Sophie
Hall,Matthew
Allen,Emma
Young,Ryan
King,Ava
Wright,Ethan
Scott,Mia
Turner,William
Carter,James
Phillips,Olivia
Evans,Lucas
Collins,Sophie
Stewart,Noah
Snyder,Ava
Baker,Ethan
Nelson,Mia
Roberts,Noah
Campbell,Emma
Miller,William
Davis,James
Garcia,Olivia
Rodriguez,Lucas
Martinez,Sophie
Hernandez,Noah
Lopez,Ava
Gonzalez,Ethan
Perez,Mia
Sanchez,William
Ramirez,James
Flores,Olivia
Cruz,Lucas
Rivera,Isabella
Lee,David
Walker,Sophie
Hall,Matthew
Allen,Emma
Young,Ryan
King,Ava
Wright,Ethan
Scott,Mia
Turner,William
Carter,James
Phillips,Olivia
Evans,Lucas
Collins,Sophie
Stewart,Noah
Snyder,Ava
Baker,Ethan
Nelson,Mia
Roberts,Noah
Campbell,Emma
Miller,William
Davis,James
Garcia,Olivia
Rodriguez,Lucas
Martinez,Sophie
Hernandez,Noah
Lopez,Ava
Gonzalez,Ethan
Perez,Mia
Sanchez,William
Ramirez,James
Flores,Olivia
Cruz,Lucas
Rivera,Isabella
Lee,David
Walker,Sophie
Hall,Matthew
Allen,Emma
Young,Ryan
King,Ava
Wright,Ethan
Scott,Mia
Turner,William
Carter,James
Phillips,Olivia
Evans,Lucas
Collins,Sophie
Stewart,Noah
Snyder,Ava
Baker,Ethan
Nelson,Mia
Roberts,Noah
Campbell,Emma
Miller,William
Davis,James
Garcia,Olivia
Rodriguez,Lucas
Martinez,Sophie
Hernandez,Noah
Lopez,Ava
Gonzalez,Ethan
Perez,Mia
Sanchez,William
Ramirez,James
Flores,Olivia
Cruz,Lucas
Rivera,Isabella
Lee,David
Walker,Sophie
Hall,Matthew
Allen,Emma
Young,Ryan
King,Ava
Wright,Ethan
Scott,Mia
Turner,William
Carter,James
Phillips,Olivia
Evans,Lucas
Collins,Sophie
Stewart,Noah
Snyder,Ava
Baker,Ethan
Nelson,Mia
Roberts,Noah
Campbell,Emma
Miller,William
Davis,James
Garcia,Olivia
Rodriguez,Lucas
Martinez,Sophie
Hernandez,Noah
Lopez,Ava
Gonzalez,Ethan
Perez,Mia
Sanchez,William
Ramirez,James
Flores,Olivia
Cruz,Lucas
Rivera,Isabella
Lee,David
Walker,Sophie
Hall,Matthew
Allen,Emma
Young,Ryan
King,Ava
Wright,Ethan
Scott,Mia
Turner,William
Carter,James
Phillips,Olivia
Evans,Lucas
Collins,Sophie
Stewart,Noah
Snyder,Ava
Baker,Ethan
Nelson,Mia
Roberts,Noah
Campbell,Emma
Miller,William
Davis,James
Garcia,Olivia
Rodriguez,Lucas
Martinez,Sophie
Hernandez,Noah
Lopez,Ava
Gonzalez,Ethan
Perez,Mia
Sanchez,William
Ramirez,James
Flores,Olivia
Cruz,Lucas
Rivera,Isabella
Lee,David
Walker,Sophie
Hall,Matthew
Allen,Emma
Young,Ryan
King,Ava
Wright,Ethan
Scott,Mia
Turner,William
Carter,James
Phillips,Olivia
Evans,Lucas
Collins,Sophie
Stewart,Noah
Snyder,Ava
Baker,Ethan
Nelson,Mia
Roberts,Noah
Campbell,Emma
Miller,William
Davis,James
Garcia,Olivia
Rodriguez,Lucas
Martinez,Sophie
Hernandez,Noah
Lopez,Ava
Gonzalez,Ethan
Perez,Mia
Sanchez,William
Ramirez,James
Flores,Olivia
Cruz,Lucas
Rivera,Isabella
Lee,David
Walker,Sophie
1 Name Vorname
2 Rodriguez Robert
3 Smith John
4 Johnson James
5 Williams William
6 Brown Michael
7 Davis David
8 Miller Richard
9 Wilson Joseph
10 Moore Charles
11 Taylor Thomas
12 Anderson Daniel
13 Thomas Paul
14 Jackson Mark
15 White Donna
16 Harris Michelle
17 Martin Laura
18 Thompson Sara
19 Garcia Ana
20 Rodriguez Carlos
21 Martinez Maria
22 Hernandez Jose
23 Lopez Luis
24 Gonzalez Rosa
25 Perez Pedro
26 Sanchez Miguel
27 Ramirez Juan
28 Flores Ana
29 Cruz Isabella
30 Rivera Victor
31 Lee Kevin
32 Walker Brian
33 Hall Emily
34 Allen Ryan
35 Young Aaron
36 King Jeffrey
37 Wright Joshua
38 Scott Brandon
39 Turner Frank
40 Carter Gregory
41 Phillips Samuel
42 Evans Chris
43 Collins Anthony
44 Stewart Eric
45 Snyder Frank
46 Baker Thomas
47 Nelson Jeremy
48 Roberts Steven
49 Campbell Edward
50 Miller Ryan
51 Davis Jacob
52 Garcia David
53 Rodriguez Sophia
54 Martinez Emma
55 Hernandez Noah
56 Lopez Ava
57 Gonzalez Ethan
58 Perez Mia
59 Sanchez William
60 Ramirez James
61 Flores Olivia
62 Cruz Lucas
63 Rivera Isabella
64 Lee David
65 Walker Sophie
66 Hall Matthew
67 Allen Emma
68 Young Ryan
69 King Ava
70 Wright Ethan
71 Scott Mia
72 Turner William
73 Carter James
74 Phillips Olivia
75 Evans Lucas
76 Collins Sophie
77 Stewart Noah
78 Snyder Ava
79 Baker Ethan
80 Nelson Mia
81 Roberts Noah
82 Campbell Emma
83 Miller William
84 Davis James
85 Garcia Olivia
86 Rodriguez Lucas
87 Martinez Sophie
88 Hernandez Noah
89 Lopez Ava
90 Gonzalez Ethan
91 Perez Mia
92 Sanchez William
93 Ramirez James
94 Flores Olivia
95 Cruz Lucas
96 Rivera Isabella
97 Lee David
98 Walker Sophie
99 Hall Matthew
100 Allen Emma
101 Young Ryan
102 King Ava
103 Wright Ethan
104 Scott Mia
105 Turner William
106 Carter James
107 Phillips Olivia
108 Evans Lucas
109 Collins Sophie
110 Stewart Noah
111 Snyder Ava
112 Baker Ethan
113 Nelson Mia
114 Roberts Noah
115 Campbell Emma
116 Miller William
117 Davis James
118 Garcia Olivia
119 Rodriguez Lucas
120 Martinez Sophie
121 Hernandez Noah
122 Lopez Ava
123 Gonzalez Ethan
124 Perez Mia
125 Sanchez William
126 Ramirez James
127 Flores Olivia
128 Cruz Lucas
129 Rivera Isabella
130 Lee David
131 Walker Sophie
132 Hall Matthew
133 Allen Emma
134 Young Ryan
135 King Ava
136 Wright Ethan
137 Scott Mia
138 Turner William
139 Carter James
140 Phillips Olivia
141 Evans Lucas
142 Collins Sophie
143 Stewart Noah
144 Snyder Ava
145 Baker Ethan
146 Nelson Mia
147 Roberts Noah
148 Campbell Emma
149 Miller William
150 Davis James
151 Garcia Olivia
152 Rodriguez Lucas
153 Martinez Sophie
154 Hernandez Noah
155 Lopez Ava
156 Gonzalez Ethan
157 Perez Mia
158 Sanchez William
159 Ramirez James
160 Flores Olivia
161 Cruz Lucas
162 Rivera Isabella
163 Lee David
164 Walker Sophie
165 Hall Matthew
166 Allen Emma
167 Young Ryan
168 King Ava
169 Wright Ethan
170 Scott Mia
171 Turner William
172 Carter James
173 Phillips Olivia
174 Evans Lucas
175 Collins Sophie
176 Stewart Noah
177 Snyder Ava
178 Baker Ethan
179 Nelson Mia
180 Roberts Noah
181 Campbell Emma
182 Miller William
183 Davis James
184 Garcia Olivia
185 Rodriguez Lucas
186 Martinez Sophie
187 Hernandez Noah
188 Lopez Ava
189 Gonzalez Ethan
190 Perez Mia
191 Sanchez William
192 Ramirez James
193 Flores Olivia
194 Cruz Lucas
195 Rivera Isabella
196 Lee David
197 Walker Sophie
198 Hall Matthew
199 Allen Emma
200 Young Ryan
201 King Ava
202 Wright Ethan
203 Scott Mia
204 Turner William
205 Carter James
206 Phillips Olivia
207 Evans Lucas
208 Collins Sophie
209 Stewart Noah
210 Snyder Ava
211 Baker Ethan
212 Nelson Mia
213 Roberts Noah
214 Campbell Emma
215 Miller William
216 Davis James
217 Garcia Olivia
218 Rodriguez Lucas
219 Martinez Sophie
220 Hernandez Noah
221 Lopez Ava
222 Gonzalez Ethan
223 Perez Mia
224 Sanchez William
225 Ramirez James
226 Flores Olivia
227 Cruz Lucas
228 Rivera Isabella
229 Lee David
230 Walker Sophie
231 Hall Matthew
232 Allen Emma
233 Young Ryan
234 King Ava
235 Wright Ethan
236 Scott Mia
237 Turner William
238 Carter James
239 Phillips Olivia
240 Evans Lucas
241 Collins Sophie
242 Stewart Noah
243 Snyder Ava
244 Baker Ethan
245 Nelson Mia
246 Roberts Noah
247 Campbell Emma
248 Miller William
249 Davis James
250 Garcia Olivia
251 Rodriguez Lucas
252 Martinez Sophie
253 Hernandez Noah
254 Lopez Ava
255 Gonzalez Ethan
256 Perez Mia
257 Sanchez William
258 Ramirez James
259 Flores Olivia
260 Cruz Lucas
261 Rivera Isabella
262 Lee David
263 Walker Sophie
264 Hall Matthew
265 Allen Emma
266 Young Ryan
267 King Ava
268 Wright Ethan
269 Scott Mia
270 Turner William
271 Carter James
272 Phillips Olivia
273 Evans Lucas
274 Collins Sophie
275 Stewart Noah
276 Snyder Ava
277 Baker Ethan
278 Nelson Mia
279 Roberts Noah
280 Campbell Emma
281 Miller William
282 Davis James
283 Garcia Olivia
284 Rodriguez Lucas
285 Martinez Sophie
286 Hernandez Noah
287 Lopez Ava
288 Gonzalez Ethan
289 Perez Mia
290 Sanchez William
291 Ramirez James
292 Flores Olivia
293 Cruz Lucas
294 Rivera Isabella
295 Lee David
296 Walker Sophie
297 Hall Matthew
298 Allen Emma
299 Young Ryan
300 King Ava
301 Wright Ethan
302 Scott Mia
303 Turner William
304 Carter James
305 Phillips Olivia
306 Evans Lucas
307 Collins Sophie
308 Stewart Noah
309 Snyder Ava
310 Baker Ethan
311 Nelson Mia
312 Roberts Noah
313 Campbell Emma
314 Miller William
315 Davis James
316 Garcia Olivia
317 Rodriguez Lucas
318 Martinez Sophie
319 Hernandez Noah
320 Lopez Ava
321 Gonzalez Ethan
322 Perez Mia
323 Sanchez William
324 Ramirez James
325 Flores Olivia
326 Cruz Lucas
327 Rivera Isabella
328 Lee David
329 Walker Sophie

View File

@@ -0,0 +1,2 @@
flask
dbcm

View File

@@ -0,0 +1,31 @@
{% extends "base.html" %}
{% block body %}
<form action="{{ url }}" method="POST">
<input type="text"
placeholder="Movie"
name="{{ select_movie }}"
id="{{ select_movie }}">
&nbsp;
<select name="{{ select_genre }}" id="{{ select_genre }}">
{% for name in data %}
<option value="{{ name }}">{{ name }}</option>
{% endfor %}
</select>
&nbsp;
<select name="{{ select_medium }}" id="{{ select_medium }}">
{% for name in data_medium %}
<option value="{{ name }}">{{ name }}</option>
{% endfor %}
</select>
&nbsp;
<select name="{{ select_regie }}" id="{{ select_regie }}">
{% for name in data_regie %}
<option value="{{ name }}">{{ name }}</option>
{% endfor %}
</select>
&nbsp;
<button type="submit"> Eingabe </button>
</form>
{% endblock %}

View File

@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head>
<title> {{ sitename }} </title>
</head>
<body>
<h2> {{ sitename }} </h2>
<p> Es werden alle Filmtitel in einer Liste angezeigt.
{% block body %}
{% endblock %}
</body>
</html>

View File

@@ -0,0 +1,10 @@
{% extends "base.html" %}
{% block body %}
<p>
Film = {{ add_movie }} <br>
Genre = {{ add_genre }} <span>&nbsp genre_id = {{ add_genre_id }} <br>
Medium = {{ add_medium }} <span>&nbsp medium_id = {{add_medium_id }} <br>
Regie = {{ add_regie }} <span>&nbsp reg_id = {{ add_regie_id }} <br>
</p>
{% endblock %}

650
movie-db/test_jup.ipynb Normal file
View File

@@ -0,0 +1,650 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "5263a987-da36-46d7-a2e7-d0658cda09c1",
"metadata": {},
"outputs": [],
"source": [
"import DBcm"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "3f6b0763-4106-4bfa-9aef-7afbd180c6d4",
"metadata": {},
"outputs": [],
"source": [
"db_name = \"movie_db.db\"\n",
"\n",
"create_my_list = \"\"\"\n",
" create table if not exists movie_list (\n",
" id integer not null primary key autoincrement,\n",
" titel varchar(64) not null,\n",
" genre_id integer not null,\n",
" regie_id integer not null\n",
" \n",
" )\n",
"\n",
"\"\"\"\n",
"\n",
"create_genre = \"\"\"\n",
" create table if not exists genre (\n",
" id integer not null primary key autoincrement,\n",
" name varchar(64) not null\n",
" )\n",
"\"\"\"\n",
"\n",
"create_regie = \"\"\"\n",
" create table if not exists regie (\n",
" id integer not null primary key autoincrement,\n",
" surname varchar(64) not null,\n",
" lastname varchr(64) not null\n",
" )\n",
"\"\"\"\n",
"\n",
"\n",
"with DBcm.UseDatabase(db_name) as db: \n",
" db.execute(create_my_list)\n",
" db.execute(create_genre)\n",
" db.execute(create_regie)\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "376ef812-97b5-45ba-8ef1-eb8d7829494a",
"metadata": {},
"outputs": [],
"source": [
"# ADDed Genre values\n",
"\n",
"ADD_GENRE_VALUE = \"\"\"\n",
" INSERT INTO genre(name)\n",
" SELECT ?\n",
" WHERE NOT EXISTS (SELECT 1 FROM genre WHERE name = ?);\n",
" \"\"\"\n",
"\n",
"with open(\"genre_list\", \"r\") as fs: \n",
" for genre_value in fs.readlines():\n",
" with DBcm.UseDatabase(db_name) as db:\n",
" db.execute(ADD_GENRE_VALUE, (genre_value.strip(), genre_value.strip()))\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "63b16a41-88bf-4832-a26c-09180832f597",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"['action', 'adventure', 'animation', 'biography', 'comedy', 'crime', 'cult movie', 'disney', 'documentary', 'drama', 'erotic', 'family', 'fantasy', 'film-noir', 'gangster', 'gay and lesbian', 'history', 'horror', 'military', 'music', 'musical', 'mystery', 'nature', 'neo-noir', 'period', 'pixar', 'road movie', 'romance', 'sci-fi', 'short', 'spy', 'super hero', 'thriller', 'visually stunning', 'war', 'western']\n"
]
}
],
"source": [
"def all_genres():\n",
" ALL_GENRE = \"\"\"\n",
" SELECT * from genre \n",
" \"\"\" \n",
" with DBcm.UseDatabase(db_name) as db:\n",
" db.execute(ALL_GENRE)\n",
" all_genre = [i[1] for i in db.fetchall()]\n",
" \n",
" return all_genre\n",
"\n",
"print(all_genres())\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "89b20b5f-34aa-4490-a4c0-c186c9fa30bd",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1\n",
"36\n"
]
}
],
"source": [
"def search_genre_id(genre_name):\n",
" GENRE_QUERY = \"\"\"\n",
" select id from genre\n",
" where name = ?\n",
" \"\"\"\n",
" try:\n",
" with DBcm.UseDatabase(db_name) as db:\n",
" db.execute(GENRE_QUERY,(genre_name,))\n",
" genre_id = db.fetchone()[0]\n",
" return int(genre_id)\n",
" except:\n",
" return int(0)\n",
"\n",
"\n",
"def search_medium_id(genre_name):\n",
" GENRE_QUERY = \"\"\"\n",
" select id from genre\n",
" where medium = ?\n",
" \"\"\"\n",
" try:\n",
" with DBcm.UseDatabase(db_name) as db:\n",
" db.execute(GENRE_QUERY,(genre_name,))\n",
" genre_id = db.fetchone()[0]\n",
" return int(genre_id)\n",
" except:\n",
" return int(0)\n",
"\n",
"print(search_genre_id(genre_name=\"action\"))\n",
"print(search_genre_id(genre_name=\"western\"))"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "c70d91a5-7855-465d-a4a6-daebc065ee37",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0-John-Smith\n",
"1-James-Johnson\n",
"2-William-Williams\n",
"3-Michael-Brown\n",
"4-David-Davis\n",
"5-Richard-Miller\n",
"6-Joseph-Wilson\n",
"7-Charles-Moore\n",
"8-Thomas-Taylor\n",
"9-Daniel-Anderson\n",
"10-Paul-Thomas\n",
"11-Mark-Jackson\n",
"12-Donna-White\n",
"13-Michelle-Harris\n",
"14-Laura-Martin\n",
"15-Sara-Thompson\n",
"16-Ana-Garcia\n",
"17-Carlos-Rodriguez\n",
"18-Maria-Martinez\n",
"19-Jose-Hernandez\n",
"20-Luis-Lopez\n",
"21-Rosa-Gonzalez\n",
"22-Pedro-Perez\n",
"23-Miguel-Sanchez\n",
"24-Juan-Ramirez\n",
"25-Ana-Flores\n",
"26-Isabella-Cruz\n",
"27-Victor-Rivera\n",
"28-Kevin-Lee\n",
"29-Brian-Walker\n",
"30-Emily-Hall\n",
"31-Ryan-Allen\n",
"32-Aaron-Young\n",
"33-Jeffrey-King\n",
"34-Joshua-Wright\n",
"35-Brandon-Scott\n",
"36-Frank-Turner\n",
"37-Gregory-Carter\n",
"38-Samuel-Phillips\n",
"39-Chris-Evans\n",
"40-Anthony-Collins\n",
"41-Eric-Stewart\n",
"42-Frank-Snyder\n",
"43-Thomas-Baker\n",
"44-Jeremy-Nelson\n",
"45-Steven-Roberts\n",
"46-Edward-Campbell\n",
"47-Ryan-Miller\n",
"48-Jacob-Davis\n",
"49-David-Garcia\n",
"50-Sophia-Rodriguez\n",
"51-Emma-Martinez\n",
"52-Noah-Hernandez\n",
"53-Ava-Lopez\n",
"54-Ethan-Gonzalez\n",
"55-Mia-Perez\n",
"56-William-Sanchez\n",
"57-James-Ramirez\n",
"58-Olivia-Flores\n",
"59-Lucas-Cruz\n",
"60-Isabella-Rivera\n",
"61-David-Lee\n",
"62-Sophie-Walker\n",
"63-Matthew-Hall\n",
"64-Emma-Allen\n",
"65-Ryan-Young\n",
"66-Ava-King\n",
"67-Ethan-Wright\n",
"68-Mia-Scott\n",
"69-William-Turner\n",
"70-James-Carter\n",
"71-Olivia-Phillips\n",
"72-Lucas-Evans\n",
"73-Sophie-Collins\n",
"74-Noah-Stewart\n",
"75-Ava-Snyder\n",
"76-Ethan-Baker\n",
"77-Mia-Nelson\n",
"78-Noah-Roberts\n",
"79-Emma-Campbell\n",
"80-William-Miller\n",
"81-James-Davis\n",
"82-Olivia-Garcia\n",
"83-Lucas-Rodriguez\n",
"84-Sophie-Martinez\n",
"85-Noah-Hernandez\n",
"86-Ava-Lopez\n",
"87-Ethan-Gonzalez\n",
"88-Mia-Perez\n",
"89-William-Sanchez\n",
"90-James-Ramirez\n",
"91-Olivia-Flores\n",
"92-Lucas-Cruz\n",
"93-Isabella-Rivera\n",
"94-David-Lee\n",
"95-Sophie-Walker\n",
"96-Matthew-Hall\n",
"97-Emma-Allen\n",
"98-Ryan-Young\n",
"99-Ava-King\n",
"100-Ethan-Wright\n",
"101-Mia-Scott\n",
"102-William-Turner\n",
"103-James-Carter\n",
"104-Olivia-Phillips\n",
"105-Lucas-Evans\n",
"106-Sophie-Collins\n",
"107-Noah-Stewart\n",
"108-Ava-Snyder\n",
"109-Ethan-Baker\n",
"110-Mia-Nelson\n",
"111-Noah-Roberts\n",
"112-Emma-Campbell\n",
"113-William-Miller\n",
"114-James-Davis\n",
"115-Olivia-Garcia\n",
"116-Lucas-Rodriguez\n",
"117-Sophie-Martinez\n",
"118-Noah-Hernandez\n",
"119-Ava-Lopez\n",
"120-Ethan-Gonzalez\n",
"121-Mia-Perez\n",
"122-William-Sanchez\n",
"123-James-Ramirez\n",
"124-Olivia-Flores\n",
"125-Lucas-Cruz\n",
"126-Isabella-Rivera\n",
"127-David-Lee\n",
"128-Sophie-Walker\n",
"129-Matthew-Hall\n",
"130-Emma-Allen\n",
"131-Ryan-Young\n",
"132-Ava-King\n",
"133-Ethan-Wright\n",
"134-Mia-Scott\n",
"135-William-Turner\n",
"136-James-Carter\n",
"137-Olivia-Phillips\n",
"138-Lucas-Evans\n",
"139-Sophie-Collins\n",
"140-Noah-Stewart\n",
"141-Ava-Snyder\n",
"142-Ethan-Baker\n",
"143-Mia-Nelson\n",
"144-Noah-Roberts\n",
"145-Emma-Campbell\n",
"146-William-Miller\n",
"147-James-Davis\n",
"148-Olivia-Garcia\n",
"149-Lucas-Rodriguez\n",
"150-Sophie-Martinez\n",
"151-Noah-Hernandez\n",
"152-Ava-Lopez\n",
"153-Ethan-Gonzalez\n",
"154-Mia-Perez\n",
"155-William-Sanchez\n",
"156-James-Ramirez\n",
"157-Olivia-Flores\n",
"158-Lucas-Cruz\n",
"159-Isabella-Rivera\n",
"160-David-Lee\n",
"161-Sophie-Walker\n",
"162-Matthew-Hall\n",
"163-Emma-Allen\n",
"164-Ryan-Young\n",
"165-Ava-King\n",
"166-Ethan-Wright\n",
"167-Mia-Scott\n",
"168-William-Turner\n",
"169-James-Carter\n",
"170-Olivia-Phillips\n",
"171-Lucas-Evans\n",
"172-Sophie-Collins\n",
"173-Noah-Stewart\n",
"174-Ava-Snyder\n",
"175-Ethan-Baker\n",
"176-Mia-Nelson\n",
"177-Noah-Roberts\n",
"178-Emma-Campbell\n",
"179-William-Miller\n",
"180-James-Davis\n",
"181-Olivia-Garcia\n",
"182-Lucas-Rodriguez\n",
"183-Sophie-Martinez\n",
"184-Noah-Hernandez\n",
"185-Ava-Lopez\n",
"186-Ethan-Gonzalez\n",
"187-Mia-Perez\n",
"188-William-Sanchez\n",
"189-James-Ramirez\n",
"190-Olivia-Flores\n",
"191-Lucas-Cruz\n",
"192-Isabella-Rivera\n",
"193-David-Lee\n",
"194-Sophie-Walker\n",
"195-Matthew-Hall\n",
"196-Emma-Allen\n",
"197-Ryan-Young\n",
"198-Ava-King\n",
"199-Ethan-Wright\n",
"200-Mia-Scott\n",
"201-William-Turner\n",
"202-James-Carter\n",
"203-Olivia-Phillips\n",
"204-Lucas-Evans\n",
"205-Sophie-Collins\n",
"206-Noah-Stewart\n",
"207-Ava-Snyder\n",
"208-Ethan-Baker\n",
"209-Mia-Nelson\n",
"210-Noah-Roberts\n",
"211-Emma-Campbell\n",
"212-William-Miller\n",
"213-James-Davis\n",
"214-Olivia-Garcia\n",
"215-Lucas-Rodriguez\n",
"216-Sophie-Martinez\n",
"217-Noah-Hernandez\n",
"218-Ava-Lopez\n",
"219-Ethan-Gonzalez\n",
"220-Mia-Perez\n",
"221-William-Sanchez\n",
"222-James-Ramirez\n",
"223-Olivia-Flores\n",
"224-Lucas-Cruz\n",
"225-Isabella-Rivera\n",
"226-David-Lee\n",
"227-Sophie-Walker\n",
"228-Matthew-Hall\n",
"229-Emma-Allen\n",
"230-Ryan-Young\n",
"231-Ava-King\n",
"232-Ethan-Wright\n",
"233-Mia-Scott\n",
"234-William-Turner\n",
"235-James-Carter\n",
"236-Olivia-Phillips\n",
"237-Lucas-Evans\n",
"238-Sophie-Collins\n",
"239-Noah-Stewart\n",
"240-Ava-Snyder\n",
"241-Ethan-Baker\n",
"242-Mia-Nelson\n",
"243-Noah-Roberts\n",
"244-Emma-Campbell\n",
"245-William-Miller\n",
"246-James-Davis\n",
"247-Olivia-Garcia\n",
"248-Lucas-Rodriguez\n",
"249-Sophie-Martinez\n",
"250-Noah-Hernandez\n",
"251-Ava-Lopez\n",
"252-Ethan-Gonzalez\n",
"253-Mia-Perez\n",
"254-William-Sanchez\n",
"255-James-Ramirez\n",
"256-Olivia-Flores\n",
"257-Lucas-Cruz\n",
"258-Isabella-Rivera\n",
"259-David-Lee\n",
"260-Sophie-Walker\n",
"261-Matthew-Hall\n",
"262-Emma-Allen\n",
"263-Ryan-Young\n",
"264-Ava-King\n",
"265-Ethan-Wright\n",
"266-Mia-Scott\n",
"267-William-Turner\n",
"268-James-Carter\n",
"269-Olivia-Phillips\n",
"270-Lucas-Evans\n",
"271-Sophie-Collins\n",
"272-Noah-Stewart\n",
"273-Ava-Snyder\n",
"274-Ethan-Baker\n",
"275-Mia-Nelson\n",
"276-Noah-Roberts\n",
"277-Emma-Campbell\n",
"278-William-Miller\n",
"279-James-Davis\n",
"280-Olivia-Garcia\n",
"281-Lucas-Rodriguez\n",
"282-Sophie-Martinez\n",
"283-Noah-Hernandez\n",
"284-Ava-Lopez\n",
"285-Ethan-Gonzalez\n",
"286-Mia-Perez\n",
"287-William-Sanchez\n",
"288-James-Ramirez\n",
"289-Olivia-Flores\n",
"290-Lucas-Cruz\n",
"291-Isabella-Rivera\n",
"292-David-Lee\n",
"293-Sophie-Walker\n",
"294-Matthew-Hall\n",
"295-Emma-Allen\n",
"296-Ryan-Young\n",
"297-Ava-King\n",
"298-Ethan-Wright\n",
"299-Mia-Scott\n",
"300-William-Turner\n",
"301-James-Carter\n",
"302-Olivia-Phillips\n",
"303-Lucas-Evans\n",
"304-Sophie-Collins\n",
"305-Noah-Stewart\n",
"306-Ava-Snyder\n",
"307-Ethan-Baker\n",
"308-Mia-Nelson\n",
"309-Noah-Roberts\n",
"310-Emma-Campbell\n",
"311-William-Miller\n",
"312-James-Davis\n",
"313-Olivia-Garcia\n",
"314-Lucas-Rodriguez\n",
"315-Sophie-Martinez\n",
"316-Noah-Hernandez\n",
"317-Ava-Lopez\n",
"318-Ethan-Gonzalez\n",
"319-Mia-Perez\n",
"320-William-Sanchez\n",
"321-James-Ramirez\n",
"322-Olivia-Flores\n",
"323-Lucas-Cruz\n",
"324-Isabella-Rivera\n",
"325-David-Lee\n",
"326-Sophie-Walker\n"
]
}
],
"source": [
"import pandas as pd\n",
"usecols = [\"Name\", \"Vorname\"]\n",
"air = pd.read_csv(\"regie_name.csv\", usecols=usecols)\n",
"\n",
"for count, (i, b) in enumerate(zip(air[\"Name\"], air[\"Vorname\"])):\n",
" print(count, b, i, sep=\"-\")\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "ee4b5dee-6b41-49eb-8d75-9db50d20fdef",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>Name</th>\n",
" <th>Vorname</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>Smith</td>\n",
" <td>John</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>Johnson</td>\n",
" <td>James</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Williams</td>\n",
" <td>William</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>Brown</td>\n",
" <td>Michael</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>Davis</td>\n",
" <td>David</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" Name Vorname\n",
"0 Smith John\n",
"1 Johnson James\n",
"2 Williams William\n",
"3 Brown Michael\n",
"4 Davis David"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import pandas as pd\n",
"air = pd.read_csv(\"regie_name.csv\", nrows=5)\n",
"air"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "8017742d-3b8e-4847-b5a3-4f28e0c9057a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Name\n",
"Flores 10.0\n",
"Davis 10.0\n",
"Gonzalez 10.0\n",
"Garcia 10.0\n",
"Cruz 10.0\n",
" ... \n",
"Taylor 1.0\n",
"White 1.0\n",
"Thompson 1.0\n",
"Wilson 1.0\n",
"Williams 1.0\n",
"Length: 47, dtype: float64\n"
]
}
],
"source": [
"chunker = pd.read_csv(\"regie_name.csv\", chunksize=1000)\n",
"tot = pd.Series([], dtype='int64')\n",
"for piece in chunker:\n",
" tot = tot.add(piece[\"Name\"].value_counts(), fill_value=0)\n",
"tot = tot.sort_values(ascending=False)\n",
"print(tot)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d7531f34-19a6-4606-88f2-1c4fdd3b0b7d",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.13.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

View File

@@ -1,4 +1,4 @@
#! /usr/bin/env python3.12
#! /usr/bin/env python3
import csv
import errno
@@ -14,7 +14,8 @@ def scan(ip):
arp_request = scapy.ARP(pdst=ip)
broadcast = scapy.Ether(dst="ff:ff:ff:ff:ff:ff")
arp_request_broadcast = broadcast / arp_request
answered_list = scapy.srp(arp_request_broadcast, timeout=1, verbose=False)[0]
answered_list = scapy.srp(arp_request_broadcast,
timeout=1, verbose=False)[0]
results = []
for element in answered_list:
result = {
@@ -45,7 +46,8 @@ def scan_csv(csvfile=str, colm="hostname"):
for count, row in enumerate(csv_reader, 1):
hostlist.append(row[colm])
else:
raise FileNotFoundError(errno.ENOENT, os.strerror(errno.ENOENT), csvfile)
raise FileNotFoundError(
errno.ENOENT, os.strerror(errno.ENOENT), csvfile)
return tuple(hostlist)
@@ -70,7 +72,8 @@ if __name__ == "__main__":
# if len(sys.argv) == 1:
ip_list = create_ip_list()
man_list = scan_csv(
csvfile=os.path.dirname(os.path.realpath(__file__)) + "/hostname_manuel.csv"
csvfile=os.path.dirname(os.path.realpath(
__file__)) + "/hostname_manuel.csv"
)
output = {
"_meta": {

File diff suppressed because it is too large Load Diff