lundi 14 mars 2016

Querying in Python

I'm building a database on python 2.7 using sqlite3 and I have reached a small problem.

Basically I have two tables which each store the following information:

Table Tweet stores: user_name, tweet_time, tweet_text

Table User stores: user_name, user_description, user_followers, user_verified, user_location

I am trying to add a function which prompts the user to enter a string, and every row in both tables which contains the submitted string, which will be found in the tweet_text column, is deleted.

The problem I'm having is that the 'User' Table does not contain a column tweet_text so I'm not sure how to delete corresponding rows in this table without actually having to add a tweet_text column.

What I have so far is just a simple delete query on the 'Tweet' Table.

delete_string = raw_input("Which string would you like to be removed from your database?: ")
c.execute("DELETE FROM Tweet WHERE tweet_text LIKE ?", ('%'+delete_string+'%',))

I'm wondering if there is any way to delete the corresponding rows in the 'User' Table without having to explicitly include tweet_text as a column.

I'm relatively inexperienced on python and this is my first time using query writing so any help will be greatly appreciated!

Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire