找回密码
 注册
查看: 711|回复: 0

R语言 RpgSQL包 pgSQL()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-27 23:53:39 | 显示全部楼层 |阅读模式
pgSQL(RpgSQL)
pgSQL()所属R语言包:RpgSQL

                                         pgSQL engine
                                         pgSQL的引擎

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

pgSQL creates a new DBI driver that can be used to start connections.
pgSQL创建一个新的DBI驱动程序,可用于启动连接。


用法----------Usage----------


        identifier.quote="\"")



参数----------Arguments----------

参数:driverClass
name of the Java class of the driver to load. If empty, it is assumed that corresponding drivers were loaded by other means.
名称的Java类加载驱动程序。如果为空,它被假定以其他方式加载相应的驱动程序。


参数:classPath
class path that needs to be appended in order to load the desired driver. Usually it is the path and file to the JAR file containing the driver. If omitted and getOption("RpgSQL_JAR") is a path and file it will use that; otherwise, if  Sys.getenv("RpgSQL_JAR") is a path and file it will use that.  If neither of those are specified or if they are paths rather than path and file then it will try to find the appropriate file looking at directories listed in the R option "RpgSQL.JAR",  the environment variable RpgSQL_JAR, the environment variable CLASSPATH and on Windows it will also look in  file.path(getenv("PROGRAMFILES"), "PostgreSLQ\pgJDBC") while on other systems it will also look in /usr/local/pgsql/share/java.
类路径需要追加以加载所需的驱动程序。通常它是包含驱动程序的JAR文件的路径和文件。如果省略,getOption("RpgSQL_JAR")是它的路径和文件都将使用该;否则,如果Sys.getenv("RpgSQL_JAR")是一个路径和文件将使用。如果没有这些规定或如果他们,而不是路径和文件的路径,然后它会尝试找到相应的文件寻找在R选项"RpgSQL.JAR",环境变量RpgSQL_JAR,环境列出的目录变量CLASSPATH和Windows上,还将寻找在file.path(getenv("PROGRAMFILES"), "PostgreSLQ\pgJDBC")而在其他系统上,它也将在/usr/local/pgsql/share/java。


参数:identifier.quote
character to use for quoting identifiers in automatically generated SQL statements or NA for no quoted identifiers.   
要使用的字符引用在自动生成的SQL语句的标识符或NA不带引号的标识符。


Details

详细信息----------Details----------

The pgSQL function initializes the Java VM, loads the pgSQL driver  and creates a proxy R object which can be used to a call dbConnect which actually creates a connection.
pgSQL函数初始化Java虚拟机的加载pgSQL的驱动程序,并创建可用于dbConnect实际上创建了一个连接到呼叫代理的R对象。

Note that these options can be defined: "RpgSQL.url",  "RpgSQL.host", "RpgSQL.port", "RpgSQL.dbname" as illustrated in the examples below.  If "RpgSQL.url" is defined it takes precedence over the others.   If the dbConnect method can explicitly specify any of these then the explicitly specified ones override the options.
请注意,这些选项可以定义:"RpgSQL.url","RpgSQL.host","RpgSQL.port","RpgSQL.dbname"在下面的例子所示。如果"RpgSQL.url"定义它的优先级比其他人。如果dbConnect方法可以明确地指定任何显式指定的覆盖选项。

Also the option "RpgSQL.JAR" can be defined as the path to the PostgreSQL jar file.  It can include the filename or just be a directory in which case it will attempt to find the jar file in that directory.  It can also be a glob expression in which case it will look among those. The jar file location can alternately be specified in an environment variable RPGSQL_JAR which is only used if the option is not specified.  Also the pgSQL function can specify the jar file location in which case the option and environment variable are ignored.
选项“"RpgSQL.JAR"还可以定义的PostgreSQL的jar文件的路径。它可以包括文件名,或仅仅是一个目录,在这种情况下,它会尝试找到在该目录下的jar文件。它也可以是一个全局的表达,在这种情况下,它看起来会是那些。 jar文件的位置可以交替的环境变量中指定RPGSQL_JAR“”如果没有指定该选项仅用于。 pgSQL功能可以指定jar文件的位置,在这种情况下,该选项和环境变量都将被忽略。


值----------Value----------

Returns a pgSQLDriver object that can be used in calls to dbConnect.
返回一个pgSQLDriver对象,可用于在调用dbConnect。


参见----------See Also----------

dbConnect
dbConnect


实例----------Examples----------


## Not run: [#不运行:]
# problem creating tables with lower case in the column names[较低的情况下,在创建表的列名问题]
library(RJDBC)

# Can put something like this into .Rprofile if you wish to change the[可以把这样的东西到。Rprofile如果你想改变]
# JVM parameters.  The value here is the default:[JVM参数。这里的值是默认的:]
#   options(java.parameters = "-Xmx512m")[java.parameters =“-Xmx512m”选项()]

# Can put something like this into .Rprofile so[可以把这样的东西。Rprofile]
# user and password need not be specified in every session.[无需指定用户名和密码,在每次会话中。]
# The values in this example are actually the defaults.[在这个例子中实际上是默认值。]
#   options(RpgSQL.user = "postgres", RpgSQL.password= "", [选项(RpgSQL.user =“postgres”的,RpgSQL.password =“”,]
#         RpgSQL.dbname = "test", RpgSQL.host = "localhost", RpgSQL.port = 5432)[RpgSQL.dbname =“测试”,RpgSQL.host的“localhost”,= 5432 RpgSQL.port)]
# or just:[或:]
#   options(RpgSQL.url = "jdbc:postgresql://localhost:5432/test")[选项(RpgSQL.url =“的jdbc:postgresql的:/ /本地主机:5432/test”的的)]

# the user/password/dbname used here are actually the defaults[这里所用的用户名/密码/数据库实际上是默认]
con <- dbConnect(pgSQL(), user = "postgres", password = "", dbname = "test",
        host = "localhost", port = 5432)

# show databases[显示数据库]
dbGetQuery(con, "select datname from pg_database")

# show tables[显示表]
tabs <- dbGetQuery(con, "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'")
tabs

# If DF already exists drop it first[如果DF已经存在,把它第一]
# if ("DF" [(“DF”]

# create DF and populate it - DF actually stored as df[DF和填充 -  DF实际存储为DF]
# This example requires RpgSQL 0.1-4.1 or later.[这个例子需要RpgSQL 0.1-4.1或更高版本。]
ct <- 'CREATE TABLE DF ("a" INTEGER, "b" VARCHAR(255), "c" DATE,"d" DOUBLE PRECISION)'
dbSendUpdate(con, ct)
dbSendUpdate(con, "insert into DF values(1, 'Hello', to_date('2000-01-01', 'YYYY-MM-DD'), 32)")
dbSendUpdate(con, "insert into DF values(2, 'Hello', to_date(NULL, 'YYYY-MM-DD'), 33)")

# query DF[查询DF]
dbGetQuery(con, "select * from DF")
res <- dbSendQuery(con, "select * from DF")
dbHasCompleted(res)
fetch(res, 1)
dbHasCompleted(res)
dbClearResult(res)

# cleanup - delete the table we created[清理 - 删除我们创建的表]
dbSendUpdate(con, "drop table DF")

# create table, populate it, display it and delete it[创建表,填充它,显示它并删除它]
s <- 'create table tt("id" int primary key, "name" varchar(255))'
dbSendUpdate(con, s)
dbSendUpdate(con, "insert into tt values(1, 'Hello')")
dbSendUpdate(con, "insert into tt values(2, 'World')")
dbGetQuery(con, "select * from tt")
dbSendUpdate(con, "drop table tt")

# transfer a data frame to pgSQL and then display it from the database[pgSQL的传输数据框,然后显示它从数据库中]
# dbWriteTable is case sensitive[dbWriteTable是大小写敏感的]
dbWriteTable(con, "BOD", BOD)

# table names are lower cased unless double quoted[表名是小写,除非用双引号]
dbGetQuery(con, 'select * from "BOD"')
dbSendUpdate(con, 'drop table "BOD"')

dbDisconnect(con)

## End(Not run)[#(不执行)]

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-26 04:42 , Processed in 0.025673 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表