# Python

With Guinsoo in server mode, the recommended library is [psycopg2](https://pypi.org/project/psycopg2/).

{% hint style="info" %}
The database was created as **`MODE=PostgreSQL`**.

MySQL or others dialogs can be created.
{% endhint %}

```python
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()
```

