Propel Insert SQL #409

harikt opened this Issue Jun 5, 2013 · 10 comments


None yet
7 participants

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.


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=;dbname=mydb;user=root

exception is

Checking Database Versions...

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

In the AbstractCommand I did an echo

connection bookstore=mysql:host=

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="
    'mysql:host' =>
    string(9) ""
    'adapter' =>
    string(5) "mysql"

I have

# 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"?>
  <!-- Uncomment this if you have PEAR Log installed
    <datasources default="bookstore">
      <datasource id="bookstore">
        <adapter>mysql</adapter> <!-- sqlite, mysql, mssql, oracle, or pgsql -->

willdurand commented Jun 6, 2013

weird issue, it should not fail that way.


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/ Oct 21, 2013


[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=\;dbname=mydb\;user=root

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


harikt commented Dec 4, 2013

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

@harikt harikt closed this Dec 4, 2013


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?


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


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=;dbname=mydb;user=root'

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