Le 25/09/2014 18:53, Rosciuc Bogdan a écrit :
> It looks like I have to use the initialize_db script since the whole
> project is written from scratch.
>
> So let me see if I got this right.
>
> 1) I create the database Metadata by using SqlAlchemy's declarative
> model. At this moment I might not have an already existing database
> 2) I connect this Metadata to my Postgresql server
> 3) I run the initialize_db script and this checks whether the tables
> exist or not (if they don't exist they are created)
> 4) I add data to the database
>
> Is this correct? What do I do when I already created the tables in the
> postgresql server? should I delete them?

You've got three alternatives :

1- Use something like sqlautocode to dynamically build models regarding
your existing database structure
2- Migrate tables to fit your declared models
3- Delete your tables

You'll use 1 and 2 if you'd like to keep the datas stored in the
existing tables.

>
> Thanks for your answer and thanks again for reading this. 
>
>
> On Wednesday, September 24, 2014 11:49:30 PM UTC+3, Rosciuc Bogdan wrote:
>
>     Hello all,
>
>     I don't quite get the models thing in Pyramid at the moment.
>
>     I was hopping that if you create a database on a database server
>     you would be able to just make the app connect to the database and
>     get the info from there without having to build a models.py file.
>
>     I tried using the reflection strategy from SQLAlchemy but it just
>     left me with a bad taste as it's pretty complicated and it's
>     pretty hard to get it working + someone told me that using
>     reflection later (i.e: production) is a bad decision (did not
>     explain but I guess performance or keeping the app safe from attacks?)
>
>     Now, I found a code generator, generated my models from a
>     Postgresql server and tried to make them work ... but nothing
>     happens and my forms don't get processed.
>
>     What I don't get is the whole initialize_db thing (why is it
>     needed? what's the role of the whole thing?). 
>
>     Also I don't quite get the working flow: You get a .db file in
>     your folder which has the info from your database ... is this file
>     connecting to the database server when the app server starts?
>     What's the point in having a separate database server anyway if
>     you work two times (build tables on the db server, build tables in
>     the models.py file)? 
>
>     At the moment i'm blocked with not being able to get my forms
>     processed.
>
>     My project is
>     at https://github.com/rbogdy/project/tree/master/aquameter
>     <https://github.com/rbogdy/project/tree/master/aquameter> if
>     anyone can take a look maybe they can spot something.
>
>     Also if anyone could take the time to explain the "models" flow, I
>     would really really appreciate it.
>
>     Thank you for reading this,
>     Bogdan
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "pylons-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/pylons-discuss.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss.
For more options, visit https://groups.google.com/d/optout.

Reply via email to