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