Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Propel Insert SQL #409

Closed
harikt opened this Issue · 10 comments

7 participants

@harikt

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.

@harikt

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>
@willdurand
Owner

weird issue, it should not fail that way.

@robin850

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
Closed

[RFC] Documentation, Propel & Propel2 #235

@mihkel

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

@evansims evansims referenced this issue from a commit
@evansims evansims Look for build.properties and sqldb.map in appropriate directories.
Fixes propelorm/Propel2#409 by configuring appropriate working directories to access necessary files for sql:inject command.
467321a
@evansims

@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.

@harikt

Thank you for the information @evansims . And great for the :+1: PR

@harikt harikt closed this
@staabm
Collaborator

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

@willdurand
Owner

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

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

@marcj
Owner

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'
@staabm
Collaborator

@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
Something went wrong with that request. Please try again.