Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7815157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:25:46+00:00 2026-06-02T05:25:46+00:00

When using RPostgreSQL I find that I cannot use sqldf in the same way.

  • 0

When using RPostgreSQL I find that I cannot use sqldf in the same way. For example if I load the library and read in data into a data frame using the following code:

library(RPostgreSQL)
drv <- dbDriver("PostgreSQL")
con <- dbConnect(drv, host="localhost", user="postgres", password="xxx", dbname="yyy", port="5436")
rs <- dbSendQuery(con, "select * from table");                           
df<- fetch(rs, n = -1); dbClearResult(rs) 
dbDisconnect(con) 

I know have the contents of this table in the dataframe df. However if I want to run a SQL command using sqldf I would previously do something like this:

sqldf("SELECT * FROM df WHERE X > 10")

This no longer works as I get the error message:

Error in postgresqlNewConnection(drv, ...) : 
  RS-DBI driver: (could not connect postgres@localhost on dbname "test"
)
Error in !dbPreExists : invalid argument type

I assume this is operator error on my part, but I can’t figure how what arguments to supply to sqldf so that it just focuses on the data frame and does not try to connect to anything else.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T05:25:48+00:00Added an answer on June 2, 2026 at 5:25 am

    Using sqldf with RPostgreSQL

    sqldf will automatically work with the test database in PostgreSQL if it sees that RPostgreSQL is loaded. So you can create a test database in PostgreSQL and then use sqldf with that

    or, you can specify the name of a different database.

    See: sqldf FAQ 12

    Using sqldf with RSQLite

    If you want to use sqldf with RSQLite rather than with RPostgreSQL you can use sqldf‘s drv argument to force it use a non-default driver. e.g.

    sqldf("select foo from bar...",drv="SQLite")
    

    or, you can set the driver globally using the "sqldf.driver" option. From within R:

    options(sqldf.driver = "SQLite")
    

    or, another possibility if you wish to use RSQLite is to detach RPostgreSQL before you use sqldf and load it again afterwards.

    See ?sqldf for details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using RPostgreSQL to read and write data. Reading from any schema works perfectly,
Using COPY statement of PostgreSQL, we can load data from a text file into
I'm using PDO inside a database abstraction library function query that I've made. I'm
Using PostgreSQL triggers, is it possible to record the changes that have happened to
Since I'm using Postgresql and can't use LINQ to SQL, I wrote my own
I'm using PostgreSQL 9.1 and I have this data structure: A B ------- 1
I am switching from using SQLite3 to PostgreSQL, and hoped that I could populate
I need to store data that looks like this: <root> <child-one> value 1 value
I have input data that consists of a list of subject id's and 2
I am trying to create a website using Symfony and PostgreSQL. I cant find

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.