[PonyORM-list] ponyorm-list Digest, Vol 16, Issue 2

Bruce Petersen bruce.petersen at ironsafe.com
Thu Dec 4 12:12:46 UTC 2014


Hi Alexander!

Thanks very much for your suggestion (multiple Database objects).  In fact,
after reviewing our product 'straw man' architecture, it became clear we
would want multiple Database objects for a few reasons (including your
suggestion).  This works great for us - our mainstream database objects are
very static (not dynamic).  The use case for our "author" category users
may actually benefit from having their own database in Postgres (which is
what I experimented with to much success).

The more I use Pony, the more I love its simple elegance.

I really appreciate your prompt reply and thoughtful answer.

Best Regards,

Bruce


On Thu, Dec 4, 2014 at 6:00 AM, <ponyorm-list-request at ponyorm.com> wrote:

> Send ponyorm-list mailing list submissions to
>         ponyorm-list at ponyorm.com
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         /ponyorm-list
> or, via email, send a message with subject or body 'help' to
>         ponyorm-list-request at ponyorm.com
>
> You can reach the person managing the list at
>         ponyorm-list-owner at ponyorm.com
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of ponyorm-list digest..."
>
>
> Today's Topics:
>
>    1. case sensitive (Goldberg, Arthur P)
>    2. Re: case sensitive (Alexey Malashkevich)
>    3. Re: Entity Creation (Alexander Kozlovsky)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 3 Dec 2014 14:19:35 +0000
> From: "Goldberg, Arthur P" <arthur.p.goldberg at mssm.edu>
> To: Pony Object-Relational Mapper mailing list
>         <ponyorm-list at ponyorm.com>
> Subject: [PonyORM-list] case sensitive
> Message-ID: <9A65CBDB-9CD1-4682-AE41-6FB004AF1385 at mssm.edu>
> Content-Type: text/plain; charset="utf-8"
>
> Hi All
>
> I'd like DBMS string searches to case sensitive. THAT is, if 'A' is in the
> dbms, a search for 'a' shouldn't find it.
> but my DBMS is MySQL (on mac), so it is case insensitive<
> http://dev.mysql.com/doc/refman/5.6/en/case-sensitivity.html>.
>
> thoughts?
>
>
>
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> /ponyorm-list/attachments/20141203/e8df4dbd/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Thu, 4 Dec 2014 00:58:24 +0400
> From: Alexey Malashkevich <alexeymalashkevich at gmail.com>
> To: Pony Object-Relational Mapper mailing list
>         <ponyorm-list at ponyorm.com>
> Subject: Re: [PonyORM-list] case sensitive
> Message-ID:
>         <CABuFHj45Setyvg1dxSF=
> 7sN3mxiUWpRxmaWfmvacawG+-S_LcQ at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Hi Arthur,
>
> One of the approaches is to specify the case sensitive collation when you
> create your database.If you use only latin1 charaters, then you can use
> latin1_general_cs collation. If you use utf8 characters in your
> application, then you need to use utf8_bin collation:
>
> CREATE DATABASE db_name
>     [[DEFAULT] COLLATE collation_name]
>
> For example:
>
> CREATE DATABASE test COLLATE latin1_general_cs
>
> In this case all selects will be case sensitive. See more information on
> this here: http://dev.mysql.com/doc/refman/5.0/en/charset-database.html
>
> If you want only one attribute to be case sensitive, you can use the
> sql_type parameter of an attribute when you declare your entities:
>
> class MyEntity(db.Entity):
>     attr1 = Required(str, 200, sql_type='VARCHAR(200) COLLATE
> latin1_general_cs')
>     attr2 = Required(str, 200, sql_type='VARCHAR(200) COLLATE utf8_bin')
>
> In the example above attr1 uses latin1 characters and all selects will be
> case sensitive. attr2 uses utf8 characters and will be case sensitive.
>
> Here you can see all available collations for MySQL
> http://dev.mysql.com/doc/refman/5.0/en/charset-mysql.html
>
> In future we will add the ability to specify collation for attributes this
> way:
>
> class MyEntity(db.Entity):
>     attr1 = Required(str, collate='latin1_general_cs')
>     attr2 = Required(str, collate='utf8_bin')
>
> Regards,
> Alexey
>
>
> On Wed, Dec 3, 2014 at 5:19 PM, Goldberg, Arthur P <
> arthur.p.goldberg at mssm.edu> wrote:
>
> >  Hi All
> >
> >  I'd like DBMS string searches to case sensitive. THAT is, if 'A' is in
> > the dbms, a search for 'a' shouldn't find it.
> > but my DBMS is MySQL (on mac), so it is case insensitive
> > <http://dev.mysql.com/doc/refman/5.6/en/case-sensitivity.html>.
> >
> >  thoughts?
> >
> >
> >
> >
> >
> > _______________________________________________
> > ponyorm-list mailing list
> > ponyorm-list at ponyorm.com
> > /ponyorm-list
> >
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> /ponyorm-list/attachments/20141204/fabbb398/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 3
> Date: Thu, 4 Dec 2014 14:25:52 +0300
> From: Alexander Kozlovsky <alexander.kozlovsky at gmail.com>
> To: Pony Object-Relational Mapper mailing list
>         <ponyorm-list at ponyorm.com>
> Subject: Re: [PonyORM-list] Entity Creation
> Message-ID:
>         <
> CAGM6z1swWT78--AYki+CfEaVcxF6mAux0e_QOi5YFO6krCaUmg at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Hi Bruce!
>
> > We really require the ability to add an entity to the schema while the
> using application is active.
>
> Currently Pony doesn't allow to change or add entities to Database object
> after the mapping was generated. Theoretically, in the future we can allow
> it, but it will complicate internal architecture. What should we do when in
> multi-threaded application one thread starts a transaction and the other
> thread starts changing database entities? Currently the logic is simple,
> you just create all entities and then start working with them in any
> thread.
>
> > Do you have any suggestions / work-arounds (besides re-initializing the
> Database object)?
>
> If it is possible, could you describe your use-case in more detail? Why
> re-initializing of the Database object is not suitable for you?
>
> Note that you can have several Database objects working with the same
> physical database. For example, you can have one Database object for
> "static" entities which remains the same during your application lifetime,
> and the other Database object for "dynamic" entities which is created
> programmatically. When you list of "dynamic" entities is changed, you can
> do db.disconnect() for previous "dynamic" db object, and then create new db
> object with updated entity definitions. This is the example of how you can
> create entity programmatically:
>
>     from pony import orm
>     from pony.orm.core import EntityMeta
>
>     db = orm.Database()
>
>     attrs = {}
>     attrs['id'] = orm.PrimaryKey(int, auto=True)
>     attrs['name'] = orm.Required(str)
>     attrs['age'] = orm.Required(int)
>
>     Person = EntityMeta('Person', (db.Entity,), attrs)
>
>     db.bind('sqlite', ':memory:')
>     db.generate_mapping(create_tables=True)
>
>     with db_session:
>         p1 = Person(name='John', age=20)
>
> Tell me what do you think about having two Database objects in you
> application
>
>
> Regards,
> Alexander Kozlovsky
>
>
> On Wed, Dec 3, 2014 at 6:46 AM, Bruce Petersen <
> bruce.petersen at ironsafe.com>
> wrote:
>
> > Greetings!
> >
> > I'm seeing great advantages to Pony -- however, perhaps you can help me
> > through one major stumbling block:
> >
> > Our app requires that tables (and their classes) be created on-the-fly.
> > Given my understanding of the lifecycle of entity mappings, it looks like
> > entity mappings really cannot be created dynamically.  That is, it looks
> > like Pony requires that Entities need to be mapped before any using
> > application starts, yes?  Any attempt to sub-class Entity results in an
> > exception once the first generate_mapping is called.
> >
> > We really require the ability to add an entity to the schema while the
> > using application is active.  We've been using SqlAlchemy to create
> models
> > throughout the life of the application -- we were very much looking
> forward
> > to using Pony's awesome features.
> >
> > Do you have any suggestions / work-arounds (besides re-initializing the
> > Database object)?
> >
> > Many  Thanks,
> >
> > Bruce
> >
> >
> >
> >
> >
> > _______________________________________________
> > ponyorm-list mailing list
> > ponyorm-list at ponyorm.com
> > /ponyorm-list
> >
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> /ponyorm-list/attachments/20141204/d4d008b9/attachment-0001.html
> >
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> ponyorm-list mailing list
> ponyorm-list at ponyorm.com
> /ponyorm-list
>
>
> ------------------------------
>
> End of ponyorm-list Digest, Vol 16, Issue 2
> *******************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </ponyorm-list/attachments/20141204/cb17291c/attachment.html>


More information about the ponyorm-list mailing list