Remove useless transaction block

This commit is contained in:
Alessio 2021-08-22 18:20:42 -07:00
parent 1dc9511415
commit 9c944cdc5e
2 changed files with 2 additions and 12 deletions

View File

@ -39,8 +39,6 @@ func main() {
return return
} }
var err error var err error
profile, err = persistence.LoadProfile(*profile_dir) profile, err = persistence.LoadProfile(*profile_dir)
if err != nil { if err != nil {
@ -211,6 +209,7 @@ func fetch_user_feed(handle string) {
fmt.Printf("Saved %d tweets, %d retweets and %d users. Exiting successfully\n", len(tweets), len(retweets), len(users)) fmt.Printf("Saved %d tweets, %d retweets and %d users. Exiting successfully\n", len(tweets), len(retweets), len(users))
} }
func download_tweet_content(tweet_id string) { func download_tweet_content(tweet_id string) {
id, err := strconv.Atoi(tweet_id) id, err := strconv.Atoi(tweet_id)
if err != nil { if err != nil {

View File

@ -16,11 +16,7 @@ import (
func (p Profile) SaveUser(u scraper.User) error { func (p Profile) SaveUser(u scraper.User) error {
db := p.DB db := p.DB
tx, err := db.Begin() _, err := db.Exec(`
if err != nil {
return err
}
_, err = db.Exec(`
insert into users (id, display_name, handle, bio, following_count, followers_count, location, website, join_date, is_private, is_verified, profile_image_url, profile_image_local_path, banner_image_url, banner_image_local_path, pinned_tweet_id, is_content_downloaded) insert into users (id, display_name, handle, bio, following_count, followers_count, location, website, join_date, is_private, is_verified, profile_image_url, profile_image_local_path, banner_image_url, banner_image_local_path, pinned_tweet_id, is_content_downloaded)
values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
on conflict do update on conflict do update
@ -45,11 +41,6 @@ func (p Profile) SaveUser(u scraper.User) error {
return err return err
} }
err = tx.Commit()
if err != nil {
return err
}
return nil return nil
} }