Gaetan de Menten wrote:
> On Wed, Dec 2, 2009 at 21:03, vmail <[email protected]> wrote:
>
>> Hi
>> When using sqlalchemy directly, I can create a new database TEST like
>> that:
>>
>> engine = create_engine('mysql://r...@localhost/tmp echo=False)
>> metadata = MetaData(bind=engine)
>> connection = engine.connect()
>> connection.execute('CREATE DATABASE IF NOT EXISTS TEST')
>>
>> What is the corrrect way to do that from Elixir ?
>>
>
> In exactly the same way.
>
>
Thanks for the super fast reply
The following runs without errors, creates the database but not the
table ( and not the objects ) :
from elixir import setup_all, create_all, drop_all, Entity, session,
Field, Unicode, String, metadata
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
Session = sessionmaker()
engine = create_engine('mysql://r...@localhost/tmp', echo=False)
connection = engine.connect()
session = Session(bind=connection)
metadata.bind=engine
connection.execute('CREATE DATABASE IF NOT EXISTS TEST')
connection.execute('USE TEST')
class Account(Entity):
name = Field(String(30))
type = Field(String(30))
code = Field(String(30))
desc = Field(String(50))
drop_all(checkfirst=True)
setup_all()
create_all()
a = Account()
session.commit()
Am I mixing up Elixir and SqlAlchemy stuff ?
Thanks for your help
Peter
--
You received this message because you are subscribed to the Google Groups
"SQLElixir" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sqlelixir?hl=en.