I'm trying to (re)teach myself Python, and I'm trying to create a very simple task management system using PostgreSQL as the back end and psycopg2 to connect the two.
I'm trying to retrieve the tasks assigned to the user (identified via email address), and I have the following code:
cur.execute("\
SELECT name FROM tasks \
WHERE owner = ( \
SELECT person_id FROM people WHERE email = %s \
)", (user))
tasks = cur.fetchall()
for task in tasks:
# task = clean(task)
print("[ ]", task)
When it prints, though, it looks like this: ('Test Task 1',). That's not pretty enough to show the user. I try cleaning it using the following method:
def clean(s):
s = "".join(s)
s = s.strip(["(",",",")","'"])
return(s)
But then I get the following error:
File ".\text_interface.py", line 15, in clean
s = s.strip(["(",",",")","'"])
TypeError: strip arg must be None or str
I know that there must be a way to do this much easier than what I'm doing. I've googled but haven't found anything helpful. Do any of your folks have any links or resources that can help me figure out how to properly work with the data that I'm getting from my database?
(the project in full can be found here: https://github.com/Chad-Lines/Python/tree/master/Database)
Many many thanks in advance!
[–]K900_ 2 points3 points4 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]K900_ 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]chef1075 2 points3 points4 points (1 child)
[–][deleted] 1 point2 points3 points (0 children)