Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 2019 21:30
    roji commented #2307
  • Jan 31 2019 20:35
    YohDeadfall commented #2307
  • Jan 31 2019 10:20
    capan starred npgsql/npgsql
  • Jan 31 2019 06:10
    SeanFarrow synchronize #2308
  • Jan 30 2019 20:37
    austindrenski commented #2308
  • Jan 30 2019 20:37
    pentagra commented #1445
  • Jan 30 2019 20:33
    SeanFarrow commented #2308
  • Jan 30 2019 20:31
    austindrenski commented #2308
  • Jan 30 2019 20:27
    SeanFarrow commented #2308
  • Jan 30 2019 20:09
    austindrenski labeled #2308
  • Jan 30 2019 20:05
    roji commented #1520
  • Jan 30 2019 19:50
    gyzod commented #1445
  • Jan 30 2019 19:06
    SeanFarrow commented #1520
  • Jan 30 2019 18:54
    roji commented #1520
  • Jan 30 2019 18:53
    roji commented #1520
  • Jan 30 2019 18:52
    roji commented #2050
  • Jan 30 2019 18:45
    Trolldemorted commented #2050
  • Jan 30 2019 18:21
    SeanFarrow commented #1520
  • Jan 30 2019 18:16
    SeanFarrow review_requested #2308
  • Jan 30 2019 18:16
    SeanFarrow review_requested #2308
Ankkatalo
@Ankkatalo
Good evening. I'm looking for a .NET 6 version for prototyping, I guess I have to compile it myself, but what git branch or tag should I use as a basis?
Becky Conning
@beckyconning
Hi! What is the connection string, provider name and options that i need to use npgsql? thanks!
not sure even what a "provider name" is
Becky Conning
@beckyconning
ok so providername is Npgsql
now i'm doing {[CollectionName = "Tables"]}[Data]()and getting too few arguments error, will check docs.
Shay Rojansky
@roji
@GHosaPhat (and everyone else) sorry for answering so late, I was on vacation.
No, Npgsql doesn't come with a SQL parser - its job is only to take the SQL strings you provide it and send that to PostgreSQL. Parsing SQL is quite a complicated task as you've found out, especially if you start taking into accounts database-specific dialects...
@pha3z I think we covered preparation and batching in npgsql/doc#91
Jeremy Gamble
@GHosaPhat
OMG! You mean you aren't looking at code and issues 24/7 and actually took a little time for yourself? That's unacceptable! </sarcasm>
Shay Rojansky
@roji
:)
I usually try to be very reactive, so answering this late is very annoying to me
@Ankkatalo you definitely don't need to compile .NET in order to use .NET 6 - previews are released on a monthly basis. Simply go to https://dotnet.microsoft.com/download/dotnet/6.0 and download the latest preview.
Becky Conning
@beckyconning
has anyone had experience using npgsql with power bi / m / power query? the connection seems to work but i get a table like the following and i'm not sure what to do next. what i'm expecting is a dialog that allows the user to select what tables they want.
CollectionName,NumberOfRestrictions,NumberOfIdentifierParts,Data,Function
MetaDataCollections,0,0,Table,Function
Restrictions,0,0,Table,Function
Databases,1,1,Function,Function
Tables,4,3,Function,Function
Columns,4,4,Function,Function
Views,3,3,Function,Function
Users,1,1,Function,Function
Indexes,4,4,Function,Function
IndexColumns,5,5,Function,Function
Shay Rojansky
@roji
@GHosaPhat FWIW EF Core internally uses a SQL expression tree to represent the queries as it builds them - and the PG provider extends that with PG-specific constructs and language elements. So at the end of the query pipeline you actually have a full expression tree representing the query, which is then rendered into text. However, this isn't parsing - it's constructing. If you find you need to parse a completed SQL in order to tweak it, it's obviously far better to go to the source which generated it and do your thing there. But I obviously know nothing about what you're doing and you probably can't for some reason.
@beckyconning that looks like the results for NpgsqlConnection.GetSchema... What exactly are you trying to do, which SQL query?
Becky Conning
@beckyconning
@roji i'd love to have a dialog that shows the available tables for the user to select
like the "Navigator" window that comes up for other sources
i am using the following AdoDotNet.DataSource("Npgsql", "Server=redacted;Port=5432;User Id=redacted;Password=redacted;Database=redacted")
Becky Conning
@beckyconning
are the functions' meanings and arguments detailed somewhere? for example if i call {[CollectionName = "Tables"]}[Data]() then i get a too few arguments (expecting 4) error.
Jeremy Gamble
@GHosaPhat

No, Npgsql doesn't come with a SQL parser - its job is only to take the SQL strings you provide it and send that to PostgreSQL. Parsing SQL is quite a complicated task as you've found out, especially if you start taking into accounts database-specific dialects...

I totally understand. I've kinda shelved that "side project" (parsing SQL statements) for now since I can't seem to get anything working correctly with ANTLR and I'm just having my application recreate the SQL statement completely instead of trying to manipulate its individual components.

That being said, for what I'm doing - extracting/parsing the SQL statement from a Crystal Reports document, updating one or more clauses, then push the modified SQL back into the document before the final report is generated/printed - it would still be nice to instead "simply" be able to access and modify that parse tree with the tools I'm already using (instead of banging my head against the ANTLR wall). As I said, I fully realize this is a fairly "one-off" type of usage situation in the grand scheme of things and there are other, "brute-force" methods of accomplishing the same goals.

Shay Rojansky
@roji
@beckyconning here's some code for getting the list of tables:
var tables = conn.GetSchema("Tables");
foreach (DataRow tableRow in tables.Rows)
{
Console.WriteLine(tableRow["TABLE_NAME"]);
}
Some docs can be found in https://docs.microsoft.com/en-us/dotnet/framework/data/adonet/sql-server-schema-collections#tables - it's the SQL Server docs but Npgsql tries to match the behavior
Beyond that I don't know anything about powerbi so I can't help much there...
Becky Conning
@beckyconning
thank you! : )
Alberto Passalacqua
@AlbertoPa
you were on vacation, don't feel annoyed. :-)
arjanvanvugt
@arjanvanvugt
Hello. Is there any way to get this provider available on a sql server instance to run queries against Postgres directly from sql server stored procedures?
Like you would do with a linked server based on the odbc connection, but then with this provider instead? (not allowed to use odbc). Help in any direction would be appreciated :)
Shay Rojansky
@roji
@arjanvanvugt IIRC there's an (old) way to have .NET user code embedded in SQL Server, to be executed from functions/procedures. You could use Npgsql from there somehow - nothing else comes to mind.
Ankkatalo
@Ankkatalo
When I said I'm looking for a .NET 6 version for prototyping, I meant a version of Npgsql.
arjanvanvugt
@arjanvanvugt
@roji Thanks. Yes like loading the dll with assemblies / clr ? I dont know exactly how that works either but after some investigation I dont think it will be allowed for us. Found there is a commercial ole db driver as well which can be used for linked servers. Think we will be using that. Thanks for your help!
Shay Rojansky
@roji
@Ankkatalo previews of Npgsql 6.0.0 are published roughly every month on nuget.org, here's the latest: https://www.nuget.org/packages/Npgsql/6.0.0-preview3
Ankkatalo
@Ankkatalo
Ah, excellent. Thanks.
Omer Hijazi
@omerhijazi404
hey guys
im new to npgsql
i supplied correct details but it says no pg_hba.conf etc
why is that?
the db is hosted on heroku
Prutenskiy
@Prutenskiy_gitlab

Hi guys.
I have app witch configured as <TargetFrameworks>net472;netcoreapp3.1</TargetFrameworks>
I use Npgsql 4.*(try any vertions) for work with DB
INSERT\UPDATE worked fine, but when I try use bulk operation then on start app under net472 have this exception
"Void Npgsql.Bulk.NpgsqlBulkUploader..ctor(Microsoft.EntityFrameworkCore.DbContext)".

Have any some advise?

akshayjoyinfo
@akshayjoyinfo
Hello guys I am facing this issue
This steps
The solution is to call NpgsqlConnection.ReloadTypes() on your NpgsqlConnection after the citext extension is added - this will trigger a reloading of the types and should resolve your issue.
This needs to do before adddbcontext in efcore??
akshayjoyinfo
@akshayjoyinfo

var dbContext = scope.ServiceProvider.GetRequiredService<ISDbContext>();
if (dbContext.Database.GetPendingMigrations().Any())
{
dbContext.Database.Migrate();

dbContext.Database.OpenConnection();
((NpgsqlConnect)dbContext.GetDbConnection()).ReloadTypes();

}

I hope this is the fix
Evgeniy Glebov
@glebov21
Hello. Help me please. Can i use TransactionScope without prepared transactions?
If i using transactionScope, I have error: 55000: prepared transactions are disabled but i don't want enable prepared transactions
Evgeniy Glebov
@glebov21
Enlist=false solve my problem :)
Shay Rojansky
@roji
@akshayjoyinfo that's a possible fix, but note that it's discouraged to apply migrations programmatically when your program starts. See the EF Core docs on this for more info (https://docs.microsoft.com/en-us/ef/core/managing-schemas/migrations/applying?tabs=dotnet-core-cli).
@glebov21 Enlist=false means... you're not using TransactionScope at all (with your Npgsql connection). I'm not sure this is what you want...