Re: Error upon Publish

2020-05-21 Thread BeeRich33
This seems to have worked.  Just out of curiosity, is IPv6 investigated 
first manually before IPv4 for *localhost*?

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/53b851c8-a8b8-4244-a816-ff00cd5f59b5%40googlegroups.com.


Re: Error upon Publish

2020-05-12 Thread BeeRich33
I'm investigating how my postgresql is set up, seeing that the first error 
is on IPv6, which I have not set up.  The connection was set to 
"localhost", so I have forced 127.0.0.1 for testing.  

The logs aren't showing any attempts at connections, so that's why I'm so 
confused.  The third attempt by Sequel is showing up as an IPv4 *connection 
refused* error, but the database isn't reporting anything.  

More testing.

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/ecce40ab-9693-45db-bcce-9c9aef22eeb5%40googlegroups.com.


Re: Error upon Publish

2020-05-12 Thread BeeRich33
It's confusing because the database server is functioning.  A refresh 
directly after seeing this error comes up fine.  I've repeated that several 
times since this thread started.  So Sequel is saying the server is not 
functioning, then upon another trial, it gets a connection.  

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/6a72c15a-8b57-4e41-85ed-b34367c3df59%40googlegroups.com.


Re: Error upon Publish

2020-05-12 Thread BeeRich33
OK, sorry to revisit this, but it keeps happening and I'm not clear how to 
fix it.  I thought I had.  

I had to reboot.  The crontab was running and had a connection to a 
localhost table.  The logger shows the disconnection basically instantly 
after the last query was received by the script.  So I am assuming the 
*pool* had nothing for a new request to use (basically empty). 

2020-05-12 02:03:12.215 EDT [15538] LOG:  execute :  UPDATE 
ig_hashtags SET tagcount = $1, updated = now() WHERE hashtag = $2 
2020-05-12 02:03:12.215 EDT [15538] DETAIL:  parameters: $1 = '390', $2 
= 'rawfood'
2020-05-12 02:03:12.221 EDT [15538] LOG:  disconnection: session time: 0:02:
10.675 user=rich database=rich host=[local]
2020-05-12 02:03:12.221 EDT [15537] LOG:  disconnection: session time: 0:02:
10.684 user=rich database=rich host=localhost port=52273
 # new browser request denied here.
2020-05-12 02:09:10.824 EDT [15823] LOG:  connection received: host=[local] 
2020-05-12 02:09:10.826 EDT [15823] LOG:  connection authorized: user=rich 
database=rich

That browser call resulted in this error:

Error at 2:09 am:
PG::ConnectionBad: could not connect to server: Connection refused
 Is the server running on host "localhost" (::1) and accepting
 TCP/IP connections on port 5432?
could not connect to server: Connection refused
 Is the server running on host "localhost" (fe80::1) and accepting
 TCP/IP connections on port 5432?
could not connect to server: Connection refused
 Is the server running on host "localhost" (127.0.0.1) and accepting
 TCP/IP connections on port 5432?
 (Sequel::DatabaseConnectionError)

My goal is to avoid these errors completely.  I know you've told me that I 
can check the pool every single time, and you've also said it has 
overhead.  I'd like to avoid the overhead.  You've also said if there's 
nothing valid in the pool, that a new request would be made.  So I'm 
confused why it's reporting there's no valid connections, if you've said it 
would just open a new one.

Am I missing how this works?  That validation is set here:

DBHQ.pool.connection_validation_timeout = 6

The previous connection to localhost (the crontab connection) looks like it 
closed 6 minutes before my browser request.  My *validation* is set for 6 
seconds, and I'm still getting errors.  None of this seems to be coming 
together.  I just don't see how the validator is really anything but a shot 
in the dark with a guess, and even at 6 seconds it's failing.  

Is there no scenario where if there's no connections, that it just opens a 
new one?  

Cheers



-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/225c4308-9af9-4edf-b2fc-6b4447a06f24%40googlegroups.com.


Re: information_schema Queries

2020-04-27 Thread BeeRich33
Well that is much easier.  Thank you. 

Ya I was juggling two tables at 3 am.  

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/7896987f-3823-4b6e-931c-fd2b423b01d3%40googlegroups.com.


information_schema Queries

2020-04-26 Thread BeeRich33
I am trying to look into the information_schema.columns table but I can't 
seem to find it using the normal connector:

DBHR = Sequel.connect('postgres://rich@localhost:5432/rich')
fieldnames = DBHR[:columns].where(table_name: 'airports_gps').get(:
column_name)

This is what I'm trying to achieve:

select column_name from information_schema.columns where table_name = 
'airports';

I'm not sure how to get into that database and table.  *psql* is fine with 
the query, as is another client application. 

I also found this:  *PostgreSQL now uses the pg_* system catalogs instead 
of the INFORMATION schema.*

I'm just trying to get fieldnames from a table, and I'm thinking there's a 
more direct way than abstracting to a *DB.do <<*...

Any insight appreciated.  Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/66f4953a-2f17-4e1b-bd50-99ab011ca26b%40googlegroups.com.


Re: Error upon Publish

2020-04-15 Thread BeeRich33


On Wednesday, April 15, 2020 at 7:23:50 PM UTC-4, Jeremy Evans wrote:
>
> On Wednesday, April 15, 2020 at 2:52:23 PM UTC-7, BeeRich33 wrote:
>>
>> OK, I'm finding that disconnection times vary between < 1 second and 5 
>> minutes.  
>>
>> disconnection: session time: 0:03:35.335 user=rich database=alpha 
>> host=localhost port=51523
>>
>>
> Does this output indicate that after you disconnect the connection (kill 
> the socket), Sequel takes that long to handle the disconnection, or 
> something else?  I'm not sure what this disconnect time represents.
>

This is separate.  I got the loggers going with *connection* and 
*discconnection* log entries, and they were happening quicker than I had 
expected.  I couldn't find anything direct or quick to manually kill open 
sockets.  I assumed these disconnections would suffice.

I came back after some time and found another:

2020-04-15 19:19:27.865 EDT [17917] LOG:  disconnection: session time: 3:17:
36.711 user=rich database=alpha host=[local]

So over 3 hours, but for [local], not localhost.  Here's another connection 
that started up for some reason, then disappeared.  I don't know what 
instantiated it.  I have crontabs working but this doesn't seem like one of 
them.

2020-04-15 17:32:02.843 EDT [23811] LOG:  connection received: 
host=localhost port=51548
2020-04-15 17:32:02.844 EDT [23811] LOG:  connection authorized: user=rich 
database=alpha
2020-04-15 17:32:02.848 EDT [23811] LOG:  statement: SET 
standard_conforming_strings = ON
2020-04-15 17:32:02.849 EDT [23811] LOG:  statement: SET 
client_min_messages = 'WARNING'
2020-04-15 17:32:02.850 EDT [23811] LOG:  statement: SET DateStyle = 'ISO'
2020-04-15 17:32:07.869 EDT [23811] LOG:  statement: SELECT 
CAST(current_setting('server_version_num') AS integer) AS v
2020-04-15 17:37:01.235 EDT [23811] LOG:  disconnection: session time: 
0:04:58.392 user=rich database=alpha host=localhost port=51548

I'm saying that if you choose a number above 0, the connection_validator 
> extension will skip validation on checkout if the connection was checked in 
> fewer than that many seconds ago.  If you want to validate on every 
> checkout, regardless of the time since checkin, then you would use a number 
> less than 0.  The connection_validator extension does not validate on every 
> checkout by default as validation has a performance cost, and the more 
> recently the connection was checked in, the less likely it is to be invalid.
>

Ok.  I get that.  I collected the following range (sorted) since I started 
the logs:

0:00:00.015
0:00:00.022
0:00:00.027
0:00:00.041
0:00:00.057
0:00:05.068
0:00:05.071
0:00:05.073
0:00:05.213
0:00:05.298
0:00:05.307
0:00:05.317
0:00:07.324
0:00:27.537
0:00:28.004
0:00:34.885
0:01:06.986
0:01:14.123
0:01:17.118
0:01:17.441
0:01:49.220
0:02:29.014
0:02:46.310
0:03:35.335
0:03:48.472
0:03:48.631
0:03:52.094
0:04:58.024
0:04:58.322
0:04:58.392
0:04:58.402
0:04:58.404
0:04:58.451
0:04:58.493
0:04:58.582

So when I was getting first attempt connection errors, with no 
connection_validation, It wasn't checking the pool, and could either have 
had inactive valid connections, or no connections at all.  Either case 
would have resulted in a connection.  I was getting errors though.  That's 
where I'm confused.  

I can set it to 6 seconds, which in this small sample set, covers 12 of the 
35 entries.  
 

> If you think there is an issue here, please put together a minimal, self 
> contained example similar to the one I posted earlier.  I can then review 
> that to determine if there is a problem, and if so, hopefully how to fix it.
>

No issue, just my understanding of how it's working and how I should 
implement it.  The very reason I came to Sequel from using the PG gem as an 
ORM, was database connections.   

Theoretically, with shorter *DB.pool.connection_validation_timeout* values, 
the more connectors are instantiated, ultimately, instead of connectors to 
become available.  

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/916888f6-d218-488e-af17-0d9641ecbc35%40googlegroups.com.


Re: Error upon Publish

2020-04-15 Thread BeeRich33
OK, I'm finding that disconnection times vary between < 1 second and 5 
minutes.  

disconnection: session time: 0:03:35.335 user=rich database=alpha 
host=localhost port=51523

This is where it's confusing.  The pool is completely empty, and I should 
be getting no PG errors, but I have (am testing this again).  You're saying 
I *have to* apply *DB.pool.connection_validation_timeout = -1* in order to 
review the pool first to see if there's any open connections first?  The 
confusing bit is that if there are no valid connections, the request is 
still there.  You've stated that the timeout set to -1 is how you always 
review the pool and instantiate a new connection if there are no current 
open connections to be used.  Why is that not the case all the time?  Is it 
assumed there should be a current connection open?

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/7e71cd7f-8784-4df1-8b90-dded305fda65%40googlegroups.com.


Re: Error upon Publish

2020-04-15 Thread BeeRich33
Sorry, getting back to this.  

OK, good to know the checkin/checkout status.  

I've set this up for a DB server on the LAN.

DBNS = Sequel.connect('postgres://myun:mypw@box.local:5432/alpha')

DBNS.extension(:connection_validator)

DBNS.pool.connection_validation_timeout = -1

DBNS.log_connection_info = true

p DBNS.get(1)

# Drop the connection socket:
/([\d.]+:\d+) --> ([\d.]+:\d+)/ =~ `fstat -n | fgrep 5432`
system('tcpdrop', $1, $2)

p DBNS.get(1)

Result:

LOG:  statement: SET standard_conforming_strings = ON
LOG:  statement: SET client_min_messages = 'WARNING'
LOG:  statement: SET standard_conforming_strings = ON
LOG:  statement: SET client_min_messages = 'WARNING'
1
sh: fstat: command not found
Traceback (most recent call last):
1: from /users/rich/app2.rb:28:in `'
/users/rich/app2.rb:28:in `system': no implicit conversion of nil into 
String (TypeError)

Can't find fstat for some reason.  There's a man page.  

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/f2120076-e26c-4855-bf9c-8ac1f6080a24%40googlegroups.com.


Re: Error upon Publish

2020-03-31 Thread BeeRich33
Yes I've read the documentation several times and it is unclear.  

"Before checkout" isn't evident and leads me to believe it's at the end of 
a connection.  Why it would check the connection pool at the end of a 
connection is strange as I would expect the flushing of the pool would 
occur at the onset of a demand of a connection, regardless if the pool has 
valid open connections or not.  This is why I'm confused.  

Just now, bringing up the page again after 8 hours (which is over the 
stated default value of 1 hour), it happened again.  So the syntax I have 
in there, directly after the declaration of that constant (Sequel::Database 
connection), wouldn't it check the pool only to find no valid live 
connections.  Would it see the pool as empty and initiate a new 
connection?  

At this point I'm thinking these errors are from entries in the pool that 
are not open anymore.  And I thought the syntax provided would have flushed 
the pool upon a morning entry (my example internal website serves me only, 
so it's idle overnight).  The last request at the end of the day would 
update the single connection in the pool.  One hour later, it expires (or 
is considered expired by Sequel's default value).  It will eventually 
close, as is shown by the error.  I am under the impression that this is 
used at the beginning of a new session in the morning, hence the placement 
right behind the declaration.  I'm not clear on what I'm missing.  This 
isn't about < 60 minutes vs > 60 minutes.  This is showing up on something 
10 hours idle.  

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/b1133b93-33e1-47e3-aaa5-e085e80f330a%40googlegroups.com.


Re: Error upon Publish

2020-03-30 Thread BeeRich33
OK, I set my app to not restart for every request, and the same error came 
up with this inside my database helper:

DB = Sequel.connect('postgres://user1@localhost:5432/dbname1')
DBN = Sequel.connect('postgres://user1:secretpw@box.local:5432/dbname2')
DB.extension(:connection_validator)
DBN.extension(:connection_validator)

Obviously I've implemented it the wrong way.  I was assuming it was behind 
the scenes with respect to the connection pool, and if there were no pools 
open (default 60 minutes close time), it would initiate a new connection.  

Is this correct?  What do I have to change for connections to start if the 
pool is empty and/or all closed?

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/9445218e-7e33-4751-bdca-255954e984ed%40googlegroups.com.


Re: Month Extraction from Date Field

2020-03-21 Thread BeeRich33
Last version the best.  Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/0c38be59-7569-4c65-93f2-46c88dc70137%40googlegroups.com.


Month Extraction from Date Field

2020-03-21 Thread BeeRich33
Hi there.  I have a table with dates from over the last 11 years.  I want 
to find all "March 5th".  

I'm assuming the proper way is to call the EXTRACT function:

puts TW.where{Sequel.function(extract(:day, :month) == 3)}.sql   # => 
SELECT * FROM "points" WHERE false()

That is "extract day from month", and I've also reversed those two symbols, 
with the same result of 'false()'.

It is a date function.  I would like to manipulate both month and day so I 
can iterate through the year's days.  

The field in question is called 'day', which is a Date field '-MM-DD'.  
  

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/e880ec05-d904-473d-9e66-6ab3b281fcef%40googlegroups.com.


Aggregate as Alias

2020-03-14 Thread BeeRich33
I'm trying to perform a calculation on the sums of two columns and assign 
an alias to that calculation:

puts C.select{sum(:breading)/sum(:multiple)}.as(:average)

I got this to work, but I think there's a better way:

#{ C.select{sum(:breading)/sum(:multiple)}.first.values.first.to_f }

Can this be done?  I was expecting the result to be a hash but it doesn't 
seem to answer.  Nor does .first nor .all.

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/e4796ee4-f93c-4fd2-837b-5e1eeec6bd3b%40googlegroups.com.


Aggregate Aliases

2020-03-14 Thread BeeRich33
I'm looking to perform an average calculation from the sums of two 
columns.  I can't seem to find a way to alias the output then view that 
calculation:

This works, but there has to be a better way:

puts C.select{sum(:breading)/sum(:multiple)}.first.values.first.to_f

What I'm thinking it should look like:

puts C.select{sum(:breading)/sum(:multiple)}.as(:average)

The latter just shows the Sequel object. Inspection shows it has no 
columns, even with the alias 'average'.  

Is this this doable?

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/814a8b73-44a9-49e6-915c-f20ff529fe70%40googlegroups.com.


Groups Working?

2020-03-14 Thread BeeRich33
Posted twice, one showed up, and noted as deleted.  

Groups working?

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/5cb95b37-26b5-435f-83f5-106dd4a205a9%40googlegroups.com.


Error upon Publish

2020-03-13 Thread BeeRich33
Hi there.  

On my dev box, upon opening a site, there's a report that a connection 
dropped early and an ISE or other error came up.

I just published and this error came up in the nginx log:

2020-03-13 14:53:18 - Sequel::DatabaseDisconnectError - PG::UnableToSend: 
server closed the connection unexpectedly
App 17860 output: This probably means the server terminated abnormally
App 17860 output: before or while processing the request.
App 17860 output: :


Upon refresh/new query, it functions fine.

Is there anything I can do about this?  First connections need to be 
established for following connections to happen?

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/9d71dfd3-ee96-4fdb-ba28-c6f73edeee16%40googlegroups.com.


.where & Order

2020-02-24 Thread BeeRich33
I ran across the following, which is confusing:

DB[:table].where{(bravo > 100) & {alpha_status: 'active'}} # works
DB[:table].where{{alpha_status: 'active'} & (bravo > 100)} # error

It seems there is a preference.  I know they're in the same block, but are 
they not handled independently before the AND?

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/c31abb32-ca2c-421f-b982-c10009c4b80e%40googlegroups.com.


Re: Filtering & Subqueries

2020-02-21 Thread BeeRich33
So currently I have a dataset (an array of ids) that I plug into a 
statement that includes a join, Sequel puts all these together in the same 
trip?  That first dataset couldn't be instantiated as a constant because it 
changes.  

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/e370f63d-75bd-492b-bdfb-1f132db683fd%40googlegroups.com.


Re: Sequel Extensions

2020-02-20 Thread BeeRich33
Well there you have it.  I tripped over "extensions" in the docs and 
thought there was special treatment of these.  Heh.  

Thank you.  

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/e14bf725-34ec-45e2-ba4b-69c4e737bf96%40googlegroups.com.


Re: Filtering & Subqueries

2020-02-20 Thread BeeRich33
Actually, it turns out your .excude method is used as a subquery on a LEFT 
JOIN and it's quite a good approach.  

I was curious as I'm whipping up subqueries all the time now, which I know 
adds trips to the database.  I would sacrifice some chatter for 
understanding and dataset stability.  Quite happy in fact.  

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/7da949fb-a2f9-4591-ba90-9cf6b77a07a3%40googlegroups.com.


Sequel Extensions

2020-02-20 Thread BeeRich33
Hi there.  

I can't seem to load an extension:

Sequel.extension :earthdistance

Says it cannot load such a file.  I tried loading :cube first, but that too 
wouldn't load.  \dx shows I have both installed.  

Any insight?  Obviously PostgreSQL.  

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/f883d435-80fe-4fdd-81c6-833a8a04c1b4%40googlegroups.com.


Re: Filtering & Subqueries

2020-02-19 Thread BeeRich33
Excellent.  Thank you.  

Is the overhead much more with found sets of primary keys using an IN 
?  

Cheers


-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/a19ba8b4-8b5e-4d5d-bde5-a3f8c3970ce0%40googlegroups.com.


Re: Query Error

2020-02-18 Thread BeeRich33
This just tested, which works fine:

a = DR[:company_t].where(Sequel.ilike(:company_name, 
'%Tru%')).where(status: 'active')


-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/2d8db812-f8b0-409d-8355-e097b769f799%40googlegroups.com.


Query Error

2020-02-18 Thread BeeRich33
I get an error on the following query:

a = DR[:company_t].where(Sequel.ilike(:company_name, '%Tru%') & (status: 
'active'))


The error:

syntax error, unexpected tLABEL
...mpany_name, '%Tru%') & (*status*: 'active'))

status is a field name.  

According to the Queries documentation page, this is apparently good.  

Artist.where(Sequel.like(:name, 'Y%') & (Sequel[{b: 1}] | Sequel.~(c: 3)))


Any insight as to why this is tripping?  It doesn't like my fieldname.  

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/9345d12c-7b76-40f0-956e-bf2fd1413e53%40googlegroups.com.


Re: Filtering & Subqueries

2020-02-18 Thread BeeRich33
I'm facing items like this:

SELECT DISTINCT ON (listing_t.product_name) listing_t.product_name, 
company_t.company_name, company_t.company_address, 
  company_t.company_city, company_t.company_province, company_t.
company_url, company_t.company_phone,
FROM listing_t inner join s_ad_contracts_t on 
s_ad_contracts_t.contract_company_id 
= listing_t.product_company_id
  inner join company_t on company_t.scid = s_ad_contracts_t.
contract_company_id
WHERE company_t.status = 'active'
  AND listing_t.status = 'active'
  AND s_ad_contracts_t.contract_status = 'active'
  AND listing_t.product_name ILIKE '#{ submitted }'
ORDER BY listing_t.product_name, company_t.company_name
LIMIT 100

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/a738bd6a-8424-4b76-bfdb-6d64673f780d%40googlegroups.com.


Re: Filtering & Subqueries

2020-02-18 Thread BeeRich33
Well, I've moved to a .left_join which has me satisfied so far.  There 
isn't anything specific I'm trying to translate.  Just trying to get my 
head around this approach.  But two questions:

Given that every table that I include might have a *creation_date* field, 
how can I decipher between which table I need to select it from?  For 
clarity:

tableone.creation_at
tabletwo.creation_at

Ultimately, I'd like to use the Sequel subset capabilities in order to get 
to qualified fields in those various tables.  I've been looking for a way 
to decipher between table names, however a dataset starts with a single 
table.  At this point it's sounding like getting an array of qualified 
keyfield values for an IN statement.  The documentation for subqueries 
comes in multiple statements.  I have a three-table join that I am facing 
and it would be ideal to do this by avoiding joins.

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/2136a8f2-8015-4f1f-a0cc-a7dcce86ee7d%40googlegroups.com.


Re: Sequel.extract Day from Duration

2020-02-18 Thread BeeRich33
Solved:  Turns out there's no extraction needed.  

Sequel.cast(Time.now, Date) - Sequel.cast(:creation_at, Date)

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/401c4f3d-98e9-4eff-a85b-d3f02945caa9%40googlegroups.com.


Sequel.extract Day from Duration

2020-02-17 Thread BeeRich33
Hi there.  I'm trying to get Sequel.extract working to measure the duration 
between a queried field value and Time.now.

This is what I've been trying: (:creation_date is the date field)
# start = Date.today - 421
puts Sequel.extract(:day, Sequel.cast(Time.now, Date) - Sequel.cast(:
creation_at, Date)).as(:age)  # reference: alpha

puts Sequel[Time.now - Sequel.cast(:creation_at, Date)].extract(:day) # 
reference: bravo

Corresponding sql for PostgreSQL:

EXTRACT(day FROM (SELECT now()-creation_at)) AS age

Alpha comes up with a numeric expression but I can't seem to get anything 
out of it.  Bravo gives me errors.  I thought this would have resulted in a 
hash such as:

{:age => 421}

I'm assuming this type of extraction can be pulled out of a duration, 
seeing that this is a PostgreSQL aspect rather than Sequel.

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/55c02b19-eeaf-4ef7-98ec-4b8376201ed3%40googlegroups.com.


Filtering & Subqueries

2020-02-17 Thread BeeRich33
I'm using Dataset Filtering to narrow down a final Dataset.  

I need to grab field values from those various tables.  How can I reference 
different fields, given that this is a roundabout way of performing a 
join?  

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/a661dab4-83b8-4495-bb4a-12b3e3d3a785%40googlegroups.com.


Re: Dysfunctional Relationship?

2020-02-12 Thread BeeRich33
Excellent.  Thank you.  

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/4eab564f-2f8f-4f4d-9c41-00532e97e53d%40googlegroups.com.


Re: Dysfunctional Relationship?

2020-02-12 Thread BeeRich33
OK, just found something here.

I have two connections going on.  My projects have different connections 
belonging to different constants such as DR and DBL.  DBL was ahead of this 
DR I have here.  I moved DR above DBL (which has no :user table), and it 
worked.

Can I not have multiple connections open?  

I can see a possible conflict where two databases can have the same table 
name.  In that class declaration, Can I provide a database and table name 
as parameters instead of the sole table name?

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/f0b5a512-579c-4ef7-97af-080659eed7be%40googlegroups.com.


Dysfunctional Relationship?

2020-02-12 Thread BeeRich33
Hi there.  

I've declared a connection, which I have tested:

puts DR.inspect
DR[:user].each do |i|
  ap i
  puts
end

Works fine.  

I go to declare a class and that relationship is missing:

class User < Sequel::Model(:user)
end

PG is indicating the relation is missing:

ERROR:  relation "user" does not exist (PG::UndefinedTable)
LINE 1: SELECT * FROM "user" LIMIT 1

How does it disappear?  How can I fix this?

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/02b89bbe-fdb3-43f2-9cf9-09e652e38f5f%40googlegroups.com.


Re: PostgreSQL Error Returned?

2020-02-10 Thread BeeRich33
Ya I think there is.  That err_message I think is coming from pg, or is 
that transparent right from PostgreSQL?  Again, I haven't chased where it's 
used, so maybe it was just for development feedback.  I thought that there 
would be something like a "returning id" type of feedback, which I know 
is PostgreSQL.  In fact, I think I will be needing that soon, for inserts.  


On Monday, February 10, 2020 at 5:54:30 PM UTC-5, Jeremy Evans wrote:
>
> On Monday, February 10, 2020 at 1:04:14 PM UTC-8, BeeRich33 wrote:
>>
>> Ah ok.  
>>
>> I'm redoing some stuff, so it's not imperative I stick to anything.  
>> Essentially, leaving INSERT or DELETE commands without any capture of 
>> errors makes me lose sleep at night.  With pg, it would have 
>> res.error_message which was returned so some kind of $SDOUT or some kind of 
>> feedback.  
>>
>
> Maybe there is a misunderstanding.  With Sequel, if a database query 
> causes a database error, that is raised as a Ruby exception.  So unless you 
> are rescuing the exception and purposely choosing to ignore it, you must 
> handle it or the program stops running and outputs a backtrace.
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/0113f959-86c0-436a-a544-15f1cdd2bc44%40googlegroups.com.


Re: PostgreSQL Error Returned?

2020-02-10 Thread BeeRich33
Ah ok.  

I'm redoing some stuff, so it's not imperative I stick to anything.  
Essentially, leaving INSERT or DELETE commands without any capture of 
errors makes me lose sleep at night.  With pg, it would have 
res.error_message which was returned so some kind of $SDOUT or some kind of 
feedback.  

On Monday, February 10, 2020 at 3:46:53 PM UTC-5, Jeremy Evans wrote:
>
> On Monday, February 10, 2020 at 12:27:26 PM UTC-8, BeeRich33 wrote:
>>
>> Is there any way I can replicate a *PG* gem error message?
>>
>> return res.error_message
>>
>
> In general, Sequel wraps driver errors and uses the same message preceded 
> by the exception class name. The underlying exception is available in 
> #wrapped_exception, and maybe #cause in modern versions of Ruby.
>
> If that isn't enough information to go on, you'll have to provide an 
> example of what you want.  
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/b473859b-1510-434b-bd1b-e6c11462e874%40googlegroups.com.


PostgreSQL Error Returned?

2020-02-10 Thread BeeRich33
Is there any way I can replicate a *PG* gem error message?

return res.error_message




-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/47a18324-0f62-45bd-a3ca-8ccc29bd7904%40googlegroups.com.


Re: Mapping Tablename with Object

2020-02-03 Thread BeeRich33
A million thanks.  Saved my arse.  

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/3bce5e5a-a966-484c-89dd-e5aab29b13a3%40googlegroups.com.


Re: Mapping Tablename with Object

2020-02-03 Thread BeeRich33
I'm trying to inherit Sequel::Model but it won't see the table name, as the 
Sequel table recognition algos don't expect what they're currently named.

I tend to choose a little obscure table names as it adds a layer of 
security.  I guess it's caught me in the ass now.  Unless I'm overlooking 
something, can I keep those unexpected table names?

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/b061a16f-2fac-4948-aaae-34c8815c6cae%40googlegroups.com.


Re: .inspect Showing Empty Object

2020-01-23 Thread BeeRich33
Oh I see.  So all the functionality of that still works through Sequel 
magic I'm guessing?


-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/e04d6ac3-89bb-4a65-84da-6630a63cc378%40googlegroups.com.


Re: .inspect Showing Empty Object

2020-01-22 Thread BeeRich33
Taking out Sequel, I get expected feedback:

#
#
#
#


Cobb
4°C
nry
2020-01-23 02:49:47 -0500
On Hold


-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/c5b52cff-5ca3-4ee0-80ce-1e0d1713cd6d%40googlegroups.com.


.inspect Showing Empty Object

2020-01-22 Thread BeeRich33
Hi Sequel people.  I've read the documents from more than one source and 
it's still not working.

Code: 
DBL.create_table? :salads do  # works
  primary_key :id
  String :name, size: 200
  Integer :temp
  String :review
  DateTime :cdate
  DateTime :mdate
  String :status
end

class Salad < Sequel::Model
attr_accessor :id, :name, :temp, :review, :cdate, :mdate, :status
def initialize(args = nil)
  @name = nil
  @temp = 'cold'
  @review = 'nry'
  @cdate = Time.now
  @status = 'new' 
end
set_primary_key [:id]

#   self.strict_param_setting = false
end

a = Salad.new
puts a.inspect # empty

a.name = 'Cobb'
puts a.inspect # empty

a.temp = '4°C'
puts a.inspect # empty

a.status = 'On Hold'
puts a.inspect # empty

puts "values: #{ a.values }" # empty

puts
puts a.name # works
puts a.temp # works
puts a.review # works
puts a.cdate # works
puts a.status # works

Table created, class definition works.  Instantiation works.  Changing 
properties works.  

The issue is that the Sequel methods aren't working.

a.inspect brings up empty objects as seen below.
a.values also is empty.

Results:
#
#
#
#
values:



Cobb
4°C
nry
2020-01-23 02:30:56 -0500
On Hold

I'm sure it's something obvious, but what am I missing?  

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/2a0711dc-6bc8-4f0c-ab75-a8c001501e6b%40googlegroups.com.


Re: Variable into Sequel.cast

2020-01-20 Thread BeeRich33
OK, it was apparently working for me somehow.  Anyway, in Sequel, is this 
the proper sequence for a var placeholder?  It works but I'm confused about 
the *:interval* casting type, and its position within that Sequel.cast:

where(Sequel.cast(:login_date, Date) > Sequel.cast(Sequel::CURRENT_DATE - 
Sequel.cast((? 'days', 30) :interval), Date))

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/22c08ffe-9a03-42cd-b56b-b719fb752240%40googlegroups.com.


Re: Variable into Sequel.cast

2020-01-19 Thread BeeRich33
This is how I've been using it, now currently replaced with "30 days" 
manually.  I'd like to shove a variable in there.  

tm = PG::TypeMapByColumn.new([
  PG::TextEncoder::String.new
  ])
d = d.to_s

res = $conn.exec_params( %Q{ SELECT search_phrase, count(search_phrase) 
  FROM searches 
  WHERE creation_date::timestamp::date > (CURRENT_DATE - interval '$1 
days')::date 
AND search_phrase != 'about'
  GROUP BY search_phrase 
  ORDER BY count(search_phrase) DESC }, [ d ], 0, tm ).to_a



-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/37db9845-c5bc-4771-af53-83cef8ee29da%40googlegroups.com.


Re: Select Fields Not Empty (nil)

2020-01-19 Thread BeeRich33
Hi.  Sorry for the delay.  Fighting a now 4-week cold, been out of 
commission.

Been reading and testing some more, translating my current projects.  I try 
to post generalized examples as this isn't about anything specific.  



-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/1da11bff-dca0-45ef-916b-4c3c896f680b%40googlegroups.com.


Re: Select Fields Not Empty (nil)

2020-01-08 Thread BeeRich33

>
>
> My apologies for correcting you yet again, hence the questions here in the 
group meant for such questions:

DBS[:searches_t].
where{(exclude(search_phrase: nil))}.
select(:search_phrase, :result_count)


ERROR.  *HINT:  No function matches the given name and argument types. You 
might need to add explicit type casts. *Points to "exclude"

The "Where TRUE" is what the .sql is explaining.  From here:

where{(exclude(:search_phrase = nil) & (:client_ip != '192.168.1.4')}.

Question still not answered.  I've simplified the query to the following, 
which still has no answer:

DBS[:searches_t].
where{(exclude(search_phrase: nil))}.
select(:search_phrase, :result_count)

I've also tried:
DBS[:searches_t].
where{(:search_phrase != nil)}.
select(:search_phrase, :result_count)

=> provides nils.  So that doesn't work.

I've also tried:

DBS[:searches_t].
where{(:search_phrase !~ nil)}.
select(:search_phrase, :result_count)

=> provides nils.  Doesn't work.  

I'm reading as much as I can, and wish to avoid coming in here.  Believe 
me.  


-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/37e2cf0c-5960-4ed9-83f2-5749d04f9f27%40googlegroups.com.


Re: Select Fields Not Empty (nil)

2020-01-08 Thread BeeRich33
Just reviewed it yet again.
>
>
.invert: Nothing to invert.  What is an invert of 'field with something'?

.exclude 'any field value'?  The field values I want to avoid are *nil*, 
not ''.

'not in' doesn't apply as there's no qualifier set.

'not like' doesn't apply.  

Sequel.~ throws an error, "WHERE NOT 'search_phrase'..."

~Sequel. is not applicable.

Negated expressions, !~:  
where{(:search_phrase !~ nil)}.

...returns nil search phrases, so this doesn't work nor apply.

And that's it.  The complete section you just "hinted" about.  

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/d26f699a-6332-44b9-8186-889bb629dcb4%40googlegroups.com.


Re: Select Fields Not Empty (nil)

2020-01-08 Thread BeeRich33
You need to ask questions before accusing people.  That is plain outright 
rude.  

See, there are obviously multiple websites.  Did you know that?  I spend 
lots of time reviewing here:

http://sequel.jeremyevans.net/rdoc/files/doc/dataset_filtering_rdoc.html

So have some respect.  I'd love to not wait for anybody to get back to me.  

Nowhere on those pages, does it say anything about not returning empty 
fields.  

DBS[:searches_t].
where{(:search_phrase != nil) & (:client_ip != '192.168.1.4')}.
select(:search_phrase, Sequel.cast(:creation_date, 
DateTime).as(:creation_date), :search_type, :result_count).
reverse(:creation_date).
limit(d).sql

Doesn't resolve properly.  Nowhere in the documents does it say anything 
about this:

SELECT "search_phrase", CAST("creation_date" AS timestamp) AS 
"creation_date", "search_type", "result_count" FROM "searches_t" WHERE true 
ORDER BY "creation_date" DESC LIMIT 30


"WHERE true"?  

Show me where it's explained.  If you can't, then please understand this is 
a forum for people looking for answers.  If you don't like it, then you 
don't have to be here.  Maybe you should read the docs.  The question is 
valid.  Maybe you should be respectful and read the question.  

>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/fa442373-1a81-4267-9dbe-361a16829e6d%40googlegroups.com.


Select Fields Not Empty (nil)

2020-01-08 Thread BeeRich33
I can't seem to get a select to work on non-empty fields:

where{(:search_phrase != nil) & (:client_ip != '192.168.1.50')}.

Tried this as well:

where{(:search_phrase != '') & (:client_ip != '192.168.1.4')}.

PostgreSQL registers the field as *null*, but searches come back with *nil* 
as field values.  

How can I eliminate rows with empty fields?  Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/3d150a88-6584-4d08-b24f-90683dc156ae%40googlegroups.com.


Variable into Sequel.cast

2020-01-08 Thread BeeRich33
My PG syntax has a variable into an interval:

WHERE creation_date::timestamp::date > (CURRENT_DATE - interval '$1 days')::
date

Can I use a variable in Sequel as a parameter passed to this method, for 
use inside this interval integer?

Sequel.cast('? days', 30, :interval)


-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/5df736c2-1ac7-4314-a030-7b07ee27b40c%40googlegroups.com.


Re: Select Specific Fields from Dataset

2020-01-08 Thread BeeRich33
So why didn't that take a *Sequel.function* approach?

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/a9528c9a-f057-449f-9c21-82c736c58b95%40googlegroups.com.


Re: Select Specific Fields from Dataset

2020-01-08 Thread BeeRich33
Solved:

select(:search_phrase, Sequel.cast(:creation_date, DateTime).as(:
creation_date), :search_type, :result_count).

Formatting done in the view. 


-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/9aae2ccc-936f-4183-9d12-cc84f73570b2%40googlegroups.com.


Re: Select Specific Fields from Dataset

2020-01-08 Thread BeeRich33
Sorry, here's my original PG syntax:

res = $c.exec_params( %Q{ SELECT search_phrase, date_trunc('minute', 
creation_date), search_type, result_count...


-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/1477f911-d1d8-49ec-a027-f35e3e951832%40googlegroups.com.


Re: Select Specific Fields from Dataset

2020-01-08 Thread BeeRich33
OK, let's start fresh:

date_trunc is two pages down:  
https://www.postgresql.org/docs/9.1/functions-datetime.html


Also:  
https://www.postgresql.org/docs/9.1/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC

Truncate on timestamp:

date_trunc('hour', timestamp '2001-02-16 20:38:40')

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/366aed3b-b8d9-4341-8d01-672203d948a7%40googlegroups.com.


Re: Select Specific Fields from Dataset

2020-01-07 Thread BeeRich33
In a related application: date_trunc (this rounds up)

select{[:search_phrase, Sequel.function(:date_trunc(:minute, :creation_date
)).as(:creation_date), :search_type, :result_count]}.

That field is a timestamp, which I want to round up to the minute.  I'm 
thinking it's a PostgreSQL function, so I tried to apply it as above for 
this SQL:

date_trunc('minute', creation_date)

It's not a cast...is it?  

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/5cd5e31f-4208-48a2-9463-dc262efd7f05%40googlegroups.com.


Complex Select

2020-01-07 Thread BeeRich33
Trying to avoid *fetch* (which isn't working either), I have the following 
attempt for sequel:

SELECT hashtag, (tagcount/1000) AS tagcount
FROM myhashtags 
WHERE status = 'new' 
  AND NOT hashtag = ANY (?)
ORDER BY tagcount DESC 
LIMIT ? }, 'active', avoids, 29 ]

This is what I have:

DBL[:myhashtags].
  where(:status => 'active').
  select{ :hashtag, (Sequel.function(:tagcount/1000)) }. # => trouble 
here
  reverse(:tagcount).
  limit(29)



My *avoids* is a list of tags to not include (avoid).  I can't seem to get 
the *:tagcount/1000* to work either.  I can't seem to find anything in the 
docs that shows me how to get that done.  

Any insight appreciated as to how I can get this to work.  Even .fetch 
isn't working.  

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/7efa9f85-9b37-4756-b3e1-c904c4b400ec%40googlegroups.com.


WHERE creation_date::date > (CURRENT_DATE) - interval '30 days'::date

2020-01-06 Thread BeeRich33
Any chance I can get some leadership on that statement?  It's one *WHERE* 
clause I need to use.  

WHERE creation_date::date > (CURRENT_DATE) - interval '30 days'::date

*:creation_date* is a timestamp field.  It's tripping up on the *'30 days'* 
part.  I'm assuming I do not need any coercing to timestamp or datetime 
types.  

.where(:creation_date > (CURRENT_DATE - interval '30 days')

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/a28c242d-d4d3-42a9-8d3c-a9d69719952e%40googlegroups.com.


Re: Select Specific Fields from Dataset

2020-01-06 Thread BeeRich33
So that is always based on *:id*?

Both look great, but the first I need to remember the select syntax with 
curly braces and inner array.

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/970a96a7-3921-4892-84d8-c6f347545979%40googlegroups.com.


Re: Select Specific Fields from Dataset

2020-01-06 Thread BeeRich33

Got it.  

puts DBS[:thistable].group_and_count(:country).where(:status => 'active').
order(Sequel.desc(:country)).sql




-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/9cb0f5da-c287-4963-9537-e3ba3cb9390d%40googlegroups.com.


Select Specific Fields from Dataset

2020-01-06 Thread BeeRich33
Hi folks.  How do I select three fields from a dataset?

SELECT country, count(id) FROM "thistable" WHERE ("status" = 'active') 
GROUP BY "country" ORDER BY "country" DESC


Currently I have:

puts DBS[:thistable].where(:status => 'active').group(:country).order(Sequel
.desc(:country)).sql


So I'm missing the *country* and *count(id) *restrictions.  I'm unclear how 
to add those.  

Any insight appreciated.  Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/7ebafdc2-39d9-44a8-907a-90428e811109%40googlegroups.com.


Re: New to Sequel

2020-01-03 Thread BeeRich33
LOL yer a star.  

I'm enjoying Sequel quite a lot after two days.  


-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/0b5ac167-9aae-4437-8ede-475dd92781af%40googlegroups.com.


New to Sequel

2020-01-03 Thread BeeRich33
Hi folks.  

I'm migrating to Sequel from using the PG gem, due to the async nature of 
some of their calls.  I was getting closure on the connections so I thought 
I'd ride this train.

I have some dashboard charts that require SQL statement like the 
following.  Is it recommended that I use straight SQL for these, or can 
Sequel handle them?

res = DBN.fetch( %Q{ SELECT a."TheDate", COALESCE(b."recs", 0) mycount
FROM
(
SELECT CURRENT_DATE - i "TheDate"
  FROM generate_series(0, 29) i
) a
LEFT OUTER JOIN (
  SELECT ts::date, COUNT(*) "recs"
FROM ptree_admin
WHERE ts::date > (CURRENT_DATE - INTERVAL '30 DAY')::DATE
AND kind = 'search_done'
GROUP BY ts::date
  )b ON a."TheDate"=b.ts::date
} ).to_a

It's a bit of a doozie even for straight SQL.  Just wondering how advanced 
Sequel is.  I'm happy all the same as it provides DB.fetch.  

Cheers

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/eff37c1d-f1ff-4df7-aa04-4aaacbd70662%40googlegroups.com.


Re: Aggregate Issues

2020-01-02 Thread BeeRich33
I just found this works, but I'm still wondering why the more sql approach 
didn't work:

puts ds.where(kind: 'yellow').count

>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/d415664f-269c-40e4-8a10-9b5be42f50b9%40googlegroups.com.


Aggregate Issues

2020-01-02 Thread BeeRich33
Hi folks.  I'm new to Sequel.  I'm having a hard time trying to count 
qualified records in a working dataset, *ds*:

puts ds.count(:id).where(kind: 'yellow').sql# => undefined method 
`where' for 115:Integer (NoMethodError)

Is my syntax wrong?  I can't generate sql for it as it throws an error.

Is this improper syntax?  Any help appreciated.

Cheers


-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sequel-talk+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/819d72b4-92b2-4e38-b7a5-270e694d3228%40googlegroups.com.