Posted in
14
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
16
This Month
89
This Year
0
Add Comment
Other Items in python
Related Search Terms
Other Categories in Articles
apps forster nft pi site development tech tools and utilities utilities videos android apple apps atom bootstrap code cooking core crypto css designs factorio games google hardware how to howto ios linux mac music new world osrs php pi400 privacy python random rs3 runescape site bugs terraria valheim web development webdev windows wordpress wow wow classic