inklesspen: Yeah, I've been looking into it here these past minutes.
I need to get some... rest if not sleep.
Talk to you all soon.
tamarin_ joined the channel
tamarin_ is now known as tamarin
c0le joined the channel
johbo` joined the channel
yvl joined the channel
c0le has quit
c0le joined the channel
lszyba1 joined the channel
lszyba1
Hello, I'm reading http://pyramid-cookbook.readthedocs.org/en/late... and I can't seem to figure out if the 2nd database should be added to __init__.py? or elsewhere.. I don't want the initialize_myapp_db to touch it
rweir
wherever
pyramid cares not at all about dbs
do you mean "I'm using sqlalchemy and I'm not sure how to do models against multiple dbs"
ramteid joined the channel
sontek joined the channel
rickmak_ joined the channel
lszyba1
rweir: I mean the default DB is sqllite...when you do initlize_myapp_db it will create default tables for session,etc.... I've added a 2nd db that I will use to pull database from mysql using sqlalchemy...but I want to make sure that initilize script will not be trying to create tables in mysql...only in sqllite
tisto joined the channel
so the real question is : does the initialize_tutorial_db development.ini calls def main() in __init__ or?
tokra100 joined the channel
rweir
pyramid has no idea about dbs
lszyba1
it does...because scafold is setting it up...and by default it wants sqlite. aka sqlalchemy.url I'
x58
The scaffold is simply a tool to help you get started. If you look in scripts/initdb.py (IIRC) you can see what it is doing to create your SQLite database.
As long as you don't call the same functions on your new models/DBSession that is tied to MySQL it won't do any initialisation for you.
lszyba1
I'm adding a second one mydatabase2.url = mysql://.... now I want to add a engine2 = engine_from_config(settings, 'mydatabase2.') DBSession.configure(bind=engine2)
x58
You can't name it the same "DBSession"
so long as you make that DBSession2 you should be fine.
lszyba1
sorry DBSession2...
inside __init__....will that database be called when I do inililize_myapp_db development.ini
x58
Go read script/initdb.py which the scaffold created for you.
that is what initialize_myapp_db points to...
It's an entrypoint that is located in your setup.py
Pyramid itself is entirely database agnostic, the scaffold in this case uses sqlalchemy to give you a starter project, there is no requirement for you to use the scaffold though,
lszyba1
x58...thank you..it looks like its using DBSession DBSession.add(model)
tokra100 has left the channel
x58
There is no magic there... unless you explicitly tell it to initialise your MySQL database in that script, it just won't happen.
Explicit over implicit.
lszyba1
one more....Reflected tables ...def init_model(enigine2):.....autoload=True....does that go into __init__.py or models.py?
x58
Up to you.
You can organise the code how you see fit.
johbo` joined the channel
lszyba1
I guess model.py...now that I look at it closely and I see original DBSession is there...and I guess I'm going to have to call init_model(engine2) in __init__.py
thank you...gtg to to sleep now...resume tomorow..bye .(http://lucasmanual.com/mywiki/Pyramid/)
jhauser joined the channel
johbo` has quit
lszyba1 has left the channel
wiggy joined the channel
yvl has quit
frispete joined the channel
wiggy
morning
Ademan joined the channel
Lcaracol_ joined the channel
Lcaracol has quit
jhauser has quit
Charlie_X joined the channel
Charlie_X
Good morning.
johbo` joined the channel
cdunklau: I think I'd favour something like the repository pattern for CRUD stuff.
But for the more adventurous stuff I think I'd better tempted to use view properties. The problem with some DB stuff is that too much abstraction just creates new problems.
johbo` has quit
DRY tempts us to try and avoid writing two very similar, but subtly different queries.
I think SQLa's SQL generation code is. however, good enough for us not to worry about it too much. So writing the query where you need it seems the way to go.
digitalsatori has quit
digitalsatori joined the channel
carl- joined the channel
driti has quit
carl- joined the channel
Paradisee joined the channel
cdunklau
Charlie_X: i'm not really sure what you mean by "view properties"...
Charlie_X
Use a class for the view and use properties on it.
View methods and attributes are visible to any template.
Allows you to encapsulate stuff without littering your code with lots of utility functions.
Makes a lot of sense if you have a lot of queries for a page.
mr_jolly joined the channel
cdunklau
Charlie_X: oh good to know
johbo` joined the channel
Charlie_X: i do like the repository pattern idea. even if I have a repository method i'll only use once, it still makes things more testable
johbo` has quit
MrTango joined the channel
Charlie_X
Yes
It's basically stating the obvious. But that's often no bad thig.
areski joined the channel
cdunklau: you can have a laugh at some thoroughly untested view code