Not
  • Merhaba Dünya
  • Python
    • Sanal Ortam
    • Json
    • Cheat Sheet
    • Search
  • Javascript
    • Node
    • Vue
  • PostgreSQL
    • Install
    • Start Stop
    • Create Db
    • Backup Restore
    • Insert, Update, Delete
    • Kısa Yollar
  • Docker
    • Cheat Sheet
    • Problem
    • Komutlar
    • Örnek Konfigürasyon
    • Volume
  • Php, MySQL
  • Amazon AWS
  • Git
  • Celery
  • Mongo
    • Delete
    • Update
    • Amazon DocumentDB
  • Linux
  • Avesome
  • Bazı Bilgiler
  • Django
    • Models
    • Cheat Sheet
    • Snippets
  • Redis
  • Visual Studio Code
Powered by GitBook
On this page
  1. PostgreSQL

Insert, Update, Delete

Insert

import psycopg2

try:
    conn = psycopg2.connect(host="",database="", user="", password="")
except:
    print ("I am unable to connect to the database")

cursor = conn.cursor()

postgres_insert_query = """INSERT INTO db (name1, name2) VALUES (%s,%s)"""
record_to_insert = ('name1','name2')
cursor.execute(postgres_insert_query, record_to_insert)
conn.commit()


cursor.close()
conn.close()

PreviousBackup RestoreNextKısa Yollar

Last updated 5 years ago