Python API for PostreSQL database
Project description
A python API for managing postgresql database
Install and setup
Install third party packages:
sudo apt install python3-dev libpq-dev unixodbc-dev
To install the package
python3 -m pip install acrocord
use python in the proper environment e.g. in conda powershell
Setup database configuration and connection
SSL connection: if SSL connection is required, put the certificates given by administrator in /home/$USER/.postgresql create the folder if it does not already exist
Default connection configuration can be saved in connections.cfg in the folder /home/$USER/.postgresql/ for linux
user or typically C:\Users\$USER\.postgresql for windows user.
Example of connections.cfg:
[connection-name]
user=USERNAME
dbname=DATABASENAME
port=PORT
host=HOST
ssh=False
password=PASSWORD
[!TIP]
- the
hostfield does not recognize ssh alias, use ip address- the
portfield is typically 5432 or 5433- the name of the database is
dbname
Then in python the connection can directly be instantiate using the keyword connection-name
from acrocord import ConnectDatabase
db = ConnectDatabase()
db.connect(connection="connection-name")
Alternatively, you can use the following syntax
from acrocord import ConnectDatabase
db = ConnectDatabase()
connection = dict(
user="USERNAME",
print_sql_cmd=True,
dbname="DATABASENAME",
port="PORT",
host="HOST",
ssh=False
)
db.connect(print_sql_cmd=True, connection=connection)
Simple usage
import pandas as pd
# create schema (i.e. an independent database: requires privileges)
# write table in schema
# read table as pandas dataframe
db.create_schema("SCHEMA")
db.write_table(pd.DataFrame(1, index=[1, 2, 3], columns=[1, 2, 3]), "SCHEMA.NAME")
db.read_table("SCHEMA.NAME")
[!CAUTION]
- If the password is trivial (for local connection), add password field to the dictionary
connection- Password field can be added in
connections.cfgfile- If no password is provided python will open an log in window
- No password is needed with ssl connection
Other topics
- Deploy database: install postresgql server and create database on premise
- Manage spatial data using postgis: how to install postgis and manipulate spatial data
Author
- Eurobios Mews labs
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file acrocord-2023.3.4.tar.gz.
File metadata
- Download URL: acrocord-2023.3.4.tar.gz
- Upload date:
- Size: 34.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
663e6b5833d31f9b9bc480dcc680537960eb494d9519da2327ff5461a3d6a943
|
|
| MD5 |
930f8c257a03fbe6f2ecf242d0480739
|
|
| BLAKE2b-256 |
a9d0b17123b882a9e4239caa03eec4bbc06847e19bb8974b497d20051d67cd99
|
File details
Details for the file acrocord-2023.3.4-py3-none-any.whl.
File metadata
- Download URL: acrocord-2023.3.4-py3-none-any.whl
- Upload date:
- Size: 37.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03ef729bf3564753a8270ce08d3f23cad552a4e38ca0e07e1b6cad4ba8db0748
|
|
| MD5 |
39e371a7ec180738fc7ae9fec59c291a
|
|
| BLAKE2b-256 |
1634339ecdf498007acc9a07d1a8bfb91258c5b34697d6531769ed6d5103f382
|