Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pymysql.cursors
- import re
- cnx = pymysql.connect(host = "localhost", user = "root", password="ptekm8n8", db ="Rossmann")
- cursor = cnx.cursor()
- adress = "SELECT ADRESSE from Filialen"
- cursor.execute(adress)
- a = cursor.fetchall()
- sql_adress = []
- s = []
- cursor.execute(adress)
- for i in a:
- item = tuple(i[0].split(","))
- sql_adress.append(item[0])
- s.append(item[1].strip()) #strip() fordi "," bliver tilføjet som en værdi
- city = []
- zipcode = []
- for i in s:
- h = re.findall(r'\d{1,10}', i)
- o = re.findall(r'\D{1,100}', i)
- zipcode.append(h)
- city.append(o)
- # new_zipcode = []
- # print(zipcode)
- # for item in zipcode:
- # for inner in item:
- # new_zipcode.append(inner)
- sql_zipcode = [item for i in zipcode for item in i] #samme som ovenstående :)
- sql_city = [item.strip() for i in city for item in i] #samme princip, strip() fordi der var et whitespace i starten af hver værdi.
- print(sql_city)
- print(sql_zipcode)
- print(sql_adress)
- chain = 'SELECT kette from Filialen'
- cursor.execute(chain)
- b = cursor.fetchall()
- sql_chain = [item for i in b for item in i]
- print(sql_chain)
- #This little piggy went to the market, this little piggy stayed home, this little piggy had roast beef, this little piggy had none
- # _
- # _._ _..._ .-', _.._(`))
- # '-. ` ' /-._.-' ',/
- # ) \ '.
- # / _ _ | \
- # | a a / |
- # \ .-. ;
- # '-('' ).-' ,' ;
- # '-; | .'
- # \ \ /
- # | 7 .__ _.-\ \
- # | | | ``/ /` /
- # /,_| | /,_/ /
- # /,_/ '`-'
- #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement