RPostgres
RPostgres copied to clipboard
Unable to create table with logical column
I was not able to create a table with a logical (boolean) column using dbCreateTable
. If I define
table_a = c(col_1="character", col_2="numeric", col_3="integer")
table_b = c(col_1="character", col_2="numeric", col_3="logical")
And attempt to create them with dbCreateTable
, it works as expected for table_a
. However, it fails for table_b
giving the following Error: Failed to fetch row: ERROR: type "logical" does not exist at character 75
.
I was not able to find a mention of this in the docs or this repo's issues. My apologies in advance if this was an already considered/documented case or simply a misuse on my end.
Full MWE:
import::from(DBI, dbConnect, dbCreateTable)
import::from(RPostgres, Postgres)
table_a = c(col_1="character", col_2="numeric", col_3="integer")
table_b = c(col_1="character", col_2="numeric", col_3="logical")
# Connect to PG, replace with your credentials
conn = dbConnect(
Postgres(),
dbname="your_db",
host="your_host",
port=5432,
user="your_name",
password="your_pwd"
)
dbCreateTable(conn, "TableA", table_a, row.names=NULL)
dbCreateTable(conn, "TableB", table_b, row.names=NULL)
Adittional info:
- PG:
PostgreSQL 14.6 (Debian 14.6-1.pgdg110+1)
- DBI:
Version: 1.1.3, Source: Repository, Repository: CRAN, Hash: b2866e62bab9378c3cc9476a1954226b
- R:
Version: 4.2.2, Patched (2022-11-10 r83330), Platform: x86_64-pc-linux-gnu (64-bit)