Propel Insert SQL #409

Closed
harikt opened this Issue Jun 5, 2013 · 10 comments

Comments

Projects
None yet
7 participants
Contributor

harikt commented Jun 5, 2013

It seems the propel inser-sql nor sql:insert inserting the sql to the database

Is it a bug, or am I missing to add something.

no errors nothing is shown.

Contributor

harikt commented Jun 6, 2013

So I started to look what may be wrong.

I am doing

vendor/bin/propel migration:status --connection bookstore=mysql:host=127.0.0.1;dbname=mydb;user=root

exception is

Checking Database Versions...

  [PDOException]                                                    
  SQLSTATE[3D000]: Invalid catalog name: 1046 No database selected                        

In the AbstractCommand I did an echo

length30
connection bookstore=mysql:host=127.0.0.1

What I noticed is the extra parameters dbname etc are getting missed

The vardump of connection in MigrationStatusCommand is

array(1) {
  'bookstore' =>
  array(3) {
    'dsn' =>
    string(20) "mysql:host=127.0.0.1"
    'mysql:host' =>
    string(9) "127.0.0.1"
    'adapter' =>
    string(5) "mysql"
  }
}

I have build.properties

# Database driver
propel.database = mysql

# Project name
propel.project = bookstore

propel.database.url = mysql:host=localhost;dbname=test
propel.database.user = root
propel.database.password = password

propel.project.dir = /media/Linux/aurasystem

# The directory where Propel expects to find the XML configuration files.
propel.conf.dir = /media/Linux/aurasystem

propel.runtime.conf.file = runtime-conf.xml
propel.buildtime.conf.file = buildtime-conf.xml

and buildtime-conf.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
  <!-- Uncomment this if you have PEAR Log installed
  <log>
    <type>file</type>
    <name>/path/to/propel.log</name>
    <ident>propel-bookstore</ident>
    <level>7</level>
  </log>
  -->
  <propel>
    <datasources default="bookstore">
      <datasource id="bookstore">
        <adapter>mysql</adapter> <!-- sqlite, mysql, mssql, oracle, or pgsql -->
        <connection>
          <dsn>mysql:host=127.0.0.1;dbname=test</dsn>
          <user>root</user>
          <password>password</password>
        </connection>
      </datasource>
    </datasources>
  </propel>
</config>
Owner

willdurand commented Jun 6, 2013

weird issue, it should not fail that way.

Member

robin850 commented Oct 19, 2013

I have the exact same issue with a PostgreSQL application. The generated SQL code seems fine and there is no error when I run propel sql:insert but the tables aren't created :

$ psql foo
psql (9.3.1)
Type "help" for help.

foo=# \d
No relations found.

@robin850 robin850 referenced this issue in propelorm/propelorm.github.com Oct 21, 2013

Closed

[RFC] Documentation, Propel & Propel2 #235

mihkel commented Nov 2, 2013

Are there any improvements or updates on the issue? I'm having the same issue - sql:insert does nothing .. no errors, no tables.

evansims commented Dec 4, 2013

@harikt The semicolons are breaking up your connection string (semicolons in shell are considered returns); if you escape them it should get passed correctly.

propel insert-sql --connection bookstore=mysql:host=127.0.0.1\;dbname=mydb\;user=root

I've submitted a pull request that fixes the underlying issue with insert-sql failing, however.

Contributor

harikt commented Dec 4, 2013

Thank you for the information @evansims . And great for the 👍 PR

@harikt harikt closed this Dec 4, 2013

Member

staabm commented Dec 4, 2013

@robin850 the hint with the escaped semicolon when used from CLI should be noted somewhere in the docs, I guess?

Owner

willdurand commented Dec 4, 2013

In the UNIX doc I'd say, ; separates commands in a shell.

edit: nevermind, misread last comment. sure the doc should be updated accordingly

Owner

marcj commented Dec 4, 2013

The probably better way'd be just to surround the connection string with single quotes, also good to pass passwords that contain $ chars.

$ propel insert-sql --connection 'bookstore=mysql:host=127.0.0.1;dbname=mydb;user=root'
Member

staabm commented Dec 4, 2013

@marcj good point... we should just note in the docs which notation is prefered

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment