I want to store DB information in list

import psycopg2
connection = psycopg2.connect("********")
cur = connection.cursor()
list = []#By the way, I can't make this
cur.execute("SELECT ID FROM DB;")
list = cur
print(list)

It seems impossible to put it in directly curWhat you can get with[(1),(2),(3)]It is difficult to handle because tuple is included in the list. So I want to create a variable added as a string in the list

import psycopg2
connection = psycopg2.connect("********")
cur = connection.cursor()
list = []
cur.execute("SELECT ID FROM DB;")
for i in cur:
   list.append(str(i[0]))
print(list)

This is easy to handle because it is created like `` `[1,2,3] ```

Recommended Posts

I want to store DB information in list
I want to make the Dictionary type in the List unique
I want to print in a comprehension
I want to embed Matplotlib in PySimpleGUI
I want to do Dunnett's test in Python
I want to pin Datetime.now in Django tests
I want to create a window in Python
I want to merge nested dicts in Python
I want to sort a list in the order of other lists
I want to display the progress in Python!
[Django memo] I want to set the login user information in the form in advance
I want to see a list of WebDAV files in the Requests module
I want to store the result of% time, %% time, etc. in an object (variable)
I want to write in Python! (1) Code format check
I want to easily implement a timeout in python
I want to transition with a button in flask
I want to use self in Backpropagation (tf.custom_gradient) (tensorflow)
I want to write in Python! (2) Let's write a test
Even in JavaScript, I want to see Python `range ()`!
I want to randomly sample a file in Python
I want to work with a robot in python.
[Python] I want to make a nested list a tuple
I want to write in Python! (3) Utilize the mock
I want to use the R dataset in python
I want to do something in Python when I finish
I want to manipulate strings in Kotlin like Python!
I want to solve Sudoku (Sudoku)
I want to easily delete columns containing NA in R
I want to do something like sort uniq in Python
I want to get the operation information of yahoo route
[Go] I want to separate endpoints by Read / Write to DB
[Django] I want to log in automatically after new registration
[Introduction to Pytorch] I want to generate sentences in news articles
I want to count unique values in arrays and tuples
I want to align the significant figures in the Numpy array
I want to be able to run Python in VS Code
I want to make input () a nice complement in python
I didn't want to write the AWS key in the program
I want to understand systemd roughly
I want to scrape images to learn
I want to do ○○ with Pandas
I want to copy yolo annotations
I want to debug with Python
[Linux] I want to know the date when the user logged in
I want to solve APG4b with Python (only 4.01 and 4.04 in Chapter 4)
I want to run Rails with rails s even in vagrant environment
LINEbot development, I want to check the operation in the local environment
[Python / AWS Lambda layers] I want to reuse only module in AWS Lambda Layers
I want to acquire and list Japanese stock data without scraping
I want to create a pipfile and reflect it in docker
I want to make a parameter list from CloudFormation code (yaml)
I want to make the second line the column name in pandas
I want to pass the G test in one month Day 1
I want to know the population of each country in the world.
I want to pin Spyder to the taskbar
I want to change the color by clicking the scatter point in matplotlib
I tried to implement PLSA in Python
I want to detect objects with OpenCV
I want to output to the console coolly
I want to find variations in various statistics! Recommendation for re-sampling (Bootstrap)
I tried to implement permutation in Python