Guinsoo
GitHub
  • Welcome to Guinsoo!
  • Guides
    • Introduction
    • Quickstart
    • Features
    • Installation
    • Tutorial
      • Using the Server
      • Clients for Guinsoo
        • NodeJS
        • Go
        • Rust
        • C++
        • Python
        • Java
      • Web UI for Guinsoo
      • The Shell Tool
      • CSV Support
    • Security
    • Performance
    • Advanced
  • Reference
    • Commands
    • Functions
    • Aggregate
    • Window
    • Data Types
    • SQL Grammar
    • System Table
  • Support
    • FAQ
  • Appendix
    • Links
    • Architecture
    • Contribute
    • License
Powered by GitBook
On this page

Was this helpful?

  1. Guides
  2. Tutorial
  3. Clients for Guinsoo

Python

PreviousC++NextJava

Last updated 2 years ago

Was this helpful?

With Guinsoo in server mode, the recommended library is .

The database was created as MODE=PostgreSQL.

MySQL or others dialogs can be created.

import psycopg2

conn = psycopg2.connect(database="xxx", user="sa", password="sa", host="localhost", port="5435")
cur = conn.cursor()

cur.execute("DROP TABLE student;")
cur.execute("CREATE TABLE student(id integer, name varchar, sex varchar);")

cur.execute("INSERT INTO student(id, name, sex) VALUES(%s, %s, %s)", (1, 'Aspirin', 'M'))
cur.execute("INSERT INTO student(id, name, sex) VALUES(%s, %s, %s)", (2, 'Taxol', 'F'))
cur.execute("INSERT INTO student(id, name, sex) VALUES(%s, %s, %s)", (3, 'Dixheral', 'M'))

cur.execute("SELECT * FROM student")
results = cur.fetchall()

print(results)

conn.commit()
cur.close()
conn.close()

psycopg2