edsteva.io.postgres
PostgresData
PostgreSQL interface to run SQL queries.
This uses the file ~/.pgpass
to find the password and extra connection infos.
PARAMETER | DESCRIPTION |
---|---|
dbname |
TYPE:
|
schema |
TYPE:
|
user |
TYPE:
|
host |
TYPE:
|
port |
TYPE:
|
Examples:
>>> data = PostgresData(dbname="YOUR_DBNAME", schema="omop", user="YOUR_USERNAME")
>>> data.read_sql("select count(*) from person")
Source code in edsteva/io/postgres.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
read_sql
read_sql(sql_query: str, **kwargs) -> pd.DataFrame
Execute pandas.read_sql() on the database.
PARAMETER | DESCRIPTION |
---|---|
sql_query |
SQL query (postgres flavor)
TYPE:
|
**kwargs |
additional arguments passed to pandas.read_sql()
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
df
|
TYPE:
|
Source code in edsteva/io/postgres.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|