Para que servem commit, connection, cursor e close?
📁 iterador, python, exemplo
Exemplo básico
import psycopg2# Connect to an existing databaseconn = psycopg2.connect(""dbname=test user=postgres"")# Open a cursor to perform database operationscur = conn.cursor()# Execute a command: this creates a new tablecur.execute(""CREATE TABLE test (id serial PRIMARY KEY, num integer, data varchar);"")# Pass data to fill a query placeholders and let Psycopg perform# the correct conversion (no more SQL injections!)cur.execute(""INSERT INTO test (num, data) VALUES (%s, %s)"",... (100, ""abc'def""))# Query the dat tente assim:
list_of_words = [ ""The weather is good."", ""Hot dog is the best food,"" ""it would be a sure sign that it was still yummy."", ""The girls are beautiful."", ""Текст любой, не важно, но после бэкслэша огромное "" ""расстояние между словами. Как это исправить?""]print(*list_of_words)print()print(*list_of_words, sep='') Faça login para deixar uma resposta