Postgresql Syntax Error At End Of Input At Character
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site syntax error at the end of input c About Us Learn more about Stack Overflow the company Business Learn more about syntax error at end of input redshift hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join
Psqlexception: Error: Syntax Error At End Of Input
the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Syntax error at end of
Error: Syntax Error At End Of Input Position
input in PostgreSQL up vote 7 down vote favorite 1 I have used the next SQL statement in both MySQL and PostgreSQL, but it fails in PostgreSQL db.Query(`SELECT COUNT(*) as N FROM email WHERE address = ?`, email) with this error: pq: F:"scan.l" M:"syntax error at end of input" S:"ERROR" C:"42601" P:"50" R:"scanner_yyerror" L:"993" What's the problem? The error messages in PostgreSQL are very cryptic. sql state: 42601 sql postgresql go share|improve this question edited Oct 29 '12 at 10:40 dandan78 7,53873762 asked Oct 29 '12 at 10:26 user1243746 2 What language are you coding in? I mean the client language, not the SQL. –Mark Byers Oct 29 '12 at 10:28 1 What database client are you using? That cryptic error is much more to do with the database client than the database server. If I prepare that statement it's fine, so the issue is most likely with your programming language or database adapter. Try it in psql. PREPARE q AS SELECT COUNT(*) as N FROM email WHERE address = $1; then EXECUTE q;. $1 is the placeholder syntax for PREPARE, but your programming language probably uses ?; otherwise there's no difference. –Craig Ringer Oct 29 '12 at 10:29 add a comment| 3 Answers 3 active oldest votes up vote 15 down vote accepted You haven't provided any details about the language/environment, but I'll try a wild guess anyway: MySQL's prepared statements natively use ? as the parameter placeholder, but PostgreSQL uses $1, $2 etc. Try replacing the ? with $1 and see if it works: WHERE address = $1
pgsql-announce pgsql-bugs pgsql-docs pgsql-general pgsql-interfaces pgsql-jobs pgsql-novice pgsql-performance pgsql-php pgsql-sql pgsql-students Developer lists
Postgres Insert
Regional lists Associations User groups Project lists Inactive postgres create table lists IRC Local User Groups Featured Users International Sites Propaganda Resources Weekly News [ERROR] syntax error at end of input From: "Marcelo de Moraes Serpa"
Sign in Pricing Blog Support Search GitHub This repository Watch 116 Star 2,370 Fork 349 lib/pq Code Issues https://github.com/lib/pq/issues/350 36 Pull requests 27 Projects 0 Pulse Graphs New issue Syntax http://www.1x1.jp/blog/2007/11/cakephp_12_postgresql_schema_error.html error at end of input #350 Closed mikeroosa opened this Issue Mar 13, 2015 · 2 comments Projects None yet Labels None yet Milestone No milestone Assignees No one assigned 2 participants mikeroosa commented Mar 13, 2015 Trying to build a syntax error sample app and can't open a connection to the database. Everything works fine with psql so not sure what I'm doing wrong. db, err := sql.Open("postgres", "host=localhost dbname=postgres user=postgres password=postgres sslmode=disable") This is the error: pq: syntax error at end of input If I leave off password or username then I get a different syntax error at error. For example, if I don't include the password, I get: pq: password authentication failed for user "postgres" What is wrong with my code or setup? mikeroosa closed this Mar 13, 2015 uhoh-itsmaciek commented Mar 13, 2015 For posterity, what was wrong with your code or setup? At first glance, your connection string looks legit, so we should at least be giving a better error. mikeroosa commented Mar 13, 2015 It was a dumb error on my part. The actual syntax error was from the select statement I had on the next line. Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment Contact GitHub API Training Shop Blog About © 2016 GitHub, Inc. Terms Privacy Security Status Help You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
(月) 8:56 CakePHP | PHP この記事の所要時間: 約 2分12秒 あ,そうだ。PostgreSQL だともうなんだか色々エラーが出てるので諦めちゃいました……。 1.2を試してみました - まゆの日記 同じエラーかどうか分かりませんが、同じような現象があったので。 CakePHP1.2.0.5875 pre-betaでPostgreSQLに接続しようとすると以下のようなエラーが出ました。 Warning (2): pg_query() [function.pg-query]: Query failed: ERROR: syntax error at end of input at character 20 [CORE\cake\libs\model\datasources\dbo\dbo_postgres.php, line 123] 原因は[app/config/database.php]に追加された「schema」パラメータです。このパラメータを使うとPostgreSQLにてschemaを指定できるのですが、デフォルトの設定では空文字になっており、それをそのままDBへ発行するのでSQLエラーとなります。 解決策としてはschemaパラメータにschemaを指定します。テーブル生成時等にschemaを指定しなければデフォルトで「public」になります。個別にschemaを指定している場合はそれを設定します。 [app/config/database.php] class DATABASE_CONFIG { var $default = array( 'driver' => 'postgres', 'persistent' => false, 'host' => 'localhost', 'port' => '', 'login' => '1x1', 'password' => 'pass', 'database' => 'inquiry', // 'schema' => '', 'schema' => 'public', <--- schema 'prefix' => '', 'encoding' => '' ); } なおschemaパラメータを指定しない場合もpublicが使われます(厳密に言うとDboPostgresで定義されている値が使われます。)つまりschemaパラメータを削除してしまう手もありますが、内部動作は変わる可能性があるので、database.phpで明確に指定しておいた方が無難でしょう。 TweetPocket Related posts: CakePHP SQLをログに記録 CakePHP 環境に応じてDBの設定を変える CakePHP 任意のSQLを書く Newer: JavaScript第5版読書会#1に参加しました。 Older: あるはずのない「パチ(ンコ|スロ)での必勝法」が実はあったという話 トラックバック:0 このエントリーのトラックバックURL http://www.1x1.jp/blog/2007/11/cakephp_12_postgresql_schema_error.html/trackback Listed below