Posted in
2283
11:14 pm, March 28, 2021
Python import into SQLite research
Some examples i found while researching this import from python scripts into sqlite.
Example weather import beautiful soup
Python
def weather_():
page = requests.get("https://www.bbc.co.uk/weather/0/2643743")
soup = BeautifulSoup(page.content, 'html.parser')
today = soup.find('div',{'data-component-id' : 'forecast'})
temp = today.find(class_ = 'wr-day-temperature')
low_temp = (temp.get_text())
return low_temp
Insert into SQLite.
Python
import sqlite3
conn = sqlite3.connect('your_database.sqlite3', check_same_thread=False)
curs = conn.cursor()
curs.execute("INSERT INTO your_table_name low_temp='{}'".format(low_temp))
conn.commit()
curs.execute("INSERT INTO your_table_name low_temp=?", (low_temp,))
Insert or update
Python
INSERT INTO visits (ip, hits)
VALUES ('127.0.0.1', 1)
ON CONFLICT(ip) DO UPDATE SET hits = hits + 1;
Links
- https://stackoverflow.com/questions/50105781/how-do-i-save-beautiful-soup-outputs-into-my-sqlite-database
- https://stackoverflow.com/questions/2717590/sqlite-insert-on-duplicate-key-update-upsert
☕
View Statistics
This Week
74
This Month
315
This Year
569
Add Comment
Other Items in python
Related Search Terms
Other Categories in Articles
ai api and javascript apps bootstrap data imports docker forster funny images gaming linux marriage minecraft nft newsletters osrs operating systems photoshop pi rs3 slayer random code random things site development site updates tech tool documentation tools and utilities utilities vpn video notes videos web dev windows apps android apple apps atom bootstrap charts code code thoughts comments cooking core crypto css designs factorio games google hardware how to howto ios ideas linux mac music new world osrs php pi400 privacy python random random stats random web code random web things rs3 runescape site bugs slick slider terraria valheim videos web development webdev windows wordpress wow wow classic youtube